parameters: (tree, fn, iterable_type=tuple)
docstring: Transform all the nodes of a tree.
  
    Args:
      tree: iterable or not. If iterable, its elements (child) can also be
        iterable or not.
      fn: function to apply to each leaves.
      iterable_type: type use to construct the resulting tree for unknown
        iterable, typically `list` or `tuple`.
    Returns:
      A tree whose leaves has been transformed by `fn`.
      The hierarchy of the output tree mimics the one of the input tree.
docstring_summary: Transform all the nodes of a tree.
docstring_tokens: Transform all the nodes of a tree .
function: def transform_tree(tree, fn, iterable_type=tuple):
    """Transform all the nodes of a tree.
  
    Args:
      tree: iterable or not. If iterable, its elements (child) can also be
        iterable or not.
      fn: function to apply to each leaves.
      iterable_type: type use to construct the resulting tree for unknown
        iterable, typically `list` or `tuple`.
    Returns:
      A tree whose leaves has been transformed by `fn`.
      The hierarchy of the output tree mimics the one of the input tree.
    """
    if is_iterable(tree):
      if isinstance(tree, dict):
        res = tree.__new__(type(tree))
        res.__init__(
            (k, transform_tree(child, fn)) for k, child in iteritems(tree))
        return res
      elif isinstance(tree, tuple):
        # NamedTuple?
        if hasattr(tree, "_asdict"):
          res = tree.__new__(type(tree), **transform_tree(tree._asdict(), fn))
        else:
          res = tree.__new__(type(tree),
                             (transform_tree(child, fn) for child in tree))
        return res
      elif isinstance(tree, collections_abc.Sequence):
        res = tree.__new__(type(tree))
        res.__init__(transform_tree(child, fn) for child in tree)
        return res
      else:
        return iterable_type(transform_tree(child, fn) for child in tree)
    else:
      return fn(tree)
function_tokens: def transform_tree ( tree , fn , iterable_type = tuple ) : if is_iterable ( tree ) : if isinstance ( tree , dict ) : res = tree . __new__ ( type ( tree ) ) res . __init__ ( ( k , transform_tree ( child , fn ) ) for k , child in iteritems ( tree ) ) return res elif isinstance ( tree , tuple ) : # NamedTuple? if hasattr ( tree , "_asdict" ) : res = tree . __new__ ( type ( tree ) , * * transform_tree ( tree . _asdict ( ) , fn ) ) else : res = tree . __new__ ( type ( tree ) , ( transform_tree ( child , fn ) for child in tree ) ) return res elif isinstance ( tree , collections_abc . Sequence ) : res = tree . __new__ ( type ( tree ) ) res . __init__ ( transform_tree ( child , fn ) for child in tree ) return res else : return iterable_type ( transform_tree ( child , fn ) for child in tree ) else : return fn ( tree )