code: def accumulate(G, node, res):
      """Transform a max tree to a component tree."""
      total = G.nodes[node]["label"]
      parents = G.predecessors(node)
      for p in parents:
          total += ", " + accumulate(G, p, res)
      res[node] = total
      return total
  
file_path: scikit-image/doc/examples/developers/plot_max_tree.py
imports: import numpy
  import matplotlib.pyplot
  from matplotlib.lines import Line2D
  from skimage.morphology import max_tree
  import networkx
label_desc: Use image node_id 3 for calling a global function with example usage: accumulate(G, node, res) and returns: total