(tree)
return [tree]
Flatten a tree into a list.
Flatten a tree into a list.
Flatten a tree into a list .
def tree_flatten(tree):
  """Flatten a tree into a list."""
  if isinstance(tree, (list, tuple)):
    # In python, sum of lists starting from [] is the concatenation.
    return sum([tree_flatten(t) for t in tree], [])
  if isinstance(tree, dict):
    # Only use the values in case of a dictionary node.
    return sum([tree_flatten(v) for v in tree.values()], [])
  return [tree]
def tree_flatten ( tree ) : if isinstance ( tree , ( list , tuple ) ) : # In python, sum of lists starting from [] is the concatenation. return sum ( [ tree_flatten ( t ) for t in tree ] , [ ] ) if isinstance ( tree , dict ) : # Only use the values in case of a dictionary node. return sum ( [ tree_flatten ( v ) for v in tree . values ( ) ] , [ ] ) return [ tree ]