code: def branch(tree):
      """walking a tree bottom-up"""
  
      if not isinstance(
          tree[0], int
      ):  # assumes leaves are int for choice index
          branchsum = 0
          for b in tree:
              branchsum += branch(b)
      else:
          print(tree)
          print("final branch with", tree, sum(tree))
          if testxb:
              return sum(xb[tree])
          else:
              return sum(tree)
  
      print("working on branch", tree, branchsum)
      return branchsum
  
imports: from statsmodels.compat.python import lrange
  import numpy
label_desc: Use image node_id 1 for calling a global function with example usage: branch(tree) and returns: branchsum, sum, sum