code: def _bottom_up(net, term):
      if istask(term):
          term = (head(term),) + tuple(
              _bottom_up(net, t) for t in args(term)
          )
      elif isinstance(term, list):
          term = [_bottom_up(net, t) for t in args(term)]
      return net._rewrite(term)
  
imports: from __future__ import annotations
  from collections import deque
  from dask.core import istask, subs
label_desc: Use image node_id 4 for calling a global function with example usage: _bottom_up(net, term) and returns: net