def unflatten_tree(flattened_tree):
    """Returns the nested tree form described by the given flattened tree
  
  Inputs:
    flattened_tree - list of tuples. This is the list of tuples returned by the function 
                     flatten_tree()
  
  Returns:
    nested_tree - nested dict. The tree structure in the nested dictionary form.
  """
    nested_tree = {}
    for leaf_tuple in flattened_tree:
        current_node = nested_tree
        leaf_name = leaf_tuple[1][0]
        leaf_value = leaf_tuple[1][1]
        if len(leaf_tuple[0]) > 0:
            full_leaf_path = leaf_tuple[0] + [leaf_name]
            node_0 = full_leaf_path[0]
            for idx in range(1, len(full_leaf_path)):
                node_1 = full_leaf_path[idx]
                if isinstance(node_1, int):
                    if isinstance(current_node, dict
                        ) and node_0 not in current_node.keys():
                        current_node[node_0] = []
                    elif isinstance(current_node, list):
                        current_node.append([])
                elif isinstance(node_1, str):
                    if isinstance(current_node, dict
                        ) and node_0 not in current_node.keys():
                        current_node[node_0] = {}
                    elif isinstance(current_node, list) and node_0 >= len(
                        current_node):
                        current_node.append({})
                current_node = current_node[node_0]
                node_0 = node_1
        if isinstance(current_node, dict):
            current_node[leaf_name] = leaf_value
        else:
            current_node.append(leaf_value)
    return nested_tree
