code: def leaves(tree):
      
      lvs = []
      def _leaves(node):
          if np.isscalar(node):
              lvs.append(node)
          elif isinstance(node, tuple) and len(node) == 2:
              _leaves(node[0])
              _leaves(node[1])
          else:
              raise Exception("Not a tree!")
  
      _leaves(tree)
      return lvs
docs: Return the leaves in this subtree.