# Path: pyconll/tree/tree.py
# class Tree(Generic[T]):
#     """
#     A tree node. This is the base representation for a tree, which can have many
#     children which are accessible via child index. The tree's structure is
#     immutable, so the data, parent, children cannot be changed once created.
# 
#     As is this class is useless, and must be created with the TreeBuilder
#     module which is a sort of friend class of Tree to maintain its immutable
#     public contract.
#     """
#     def __init__(self, data: T) -> None:
#         """
#         Create a tree holding the value. Create a larger Tree, with TreeBuilder.
# 
#         Args:
#             data: The data to put with the Tree node.
#         """
#         self._data: T = data
#         self._parent: Optional['Tree[T]'] = None
#         self._children: List['Tree[T]'] = []
# 
#     @property
#     def data(self) -> T:
#         """
#         The data on the tree node. The property ensures it is readonly.
# 
#         Returns:
#             The data stored on the Tree.
#         """
#         return self._data
# 
#     @property
#     def parent(self) -> Optional['Tree[T]']:
#         """
#         Provides the parent of the Tree. The property ensures it is readonly.
# 
#         Returns:
#             A pointer to the parent Tree reference. None if there is no parent.
#         """
#         return self._parent
# 
#     @overload
#     def __getitem__(self, key: int) -> 'Tree[T]':
#         pass
# 
#     @overload
#     def __getitem__(self, key: slice) -> List['Tree[T]']:
#         pass
# 
#     def __getitem__(self, key):
#         """
#         Get specific children from the Tree. This can be an integer or slice.
# 
#         Args:
#             key: The indexer for the item.
#         """
#         return self._children[key]
# 
#     def __iter__(self) -> Iterator['Tree[T]']:
#         """
#         Provides an iterator over the children.
#         """
#         for child in self._children:
#             yield child
# 
#     def __len__(self) -> int:
#         """
#         Provides the number of direct children on the tree.
# 
#         Returns:
#             The number of direct children on the tree.
#         """
#         return len(self._children)


from typing import Any, Generic, TypeVar
from pyconll.tree.tree import Tree
    """
    A TreeBuilder is a utility to create arbitrary, immutable Trees. TreeBuilder
    works by traversing and creating a tree structure, and then providing an
    immutable view of the Tree on build. A TreeBuilder has an internal cursor
    on a Tree's node.

    A TreeBuilder can be reused to create many trees. This is useful if many
    similar Trees must be created. Note however, that if multiple Trees are
    created from the same TreeBuilder, Tree nodes will be unique, but data on
    the nodes will be shallow copies.
    """
    def __init__(self) -> None:
        """
        Creates a new empty TreeBuilder, with no internal data.
        """
        # Unfortunately, these must remain at Any since mypy cannot infer the
        # None check properly in _assert_initialization_status.
        self.root: Any = None
        self.current: Any = None
        self.constructed: bool = False

    def create_root(self, data: T) -> None:
        """
        Creates the root of the tree. This is the first step in Tree building.

        This should be called when a TreeBuilder is first created.

        Args:
            data: The optional data to put on the root node.
        """

# Path: pyconll/tree/tree.py
# class Tree(Generic[T]):
#     """
#     A tree node. This is the base representation for a tree, which can have many
#     children which are accessible via child index. The tree's structure is
#     immutable, so the data, parent, children cannot be changed once created.
# 
#     As is this class is useless, and must be created with the TreeBuilder
#     module which is a sort of friend class of Tree to maintain its immutable
#     public contract.
#     """
#     def __init__(self, data: T) -> None:
#         """
#         Create a tree holding the value. Create a larger Tree, with TreeBuilder.
# 
#         Args:
#             data: The data to put with the Tree node.
#         """
#         self._data: T = data
#         self._parent: Optional['Tree[T]'] = None
#         self._children: List['Tree[T]'] = []
# 
#     @property
#     def data(self) -> T:
#         """
#         The data on the tree node. The property ensures it is readonly.
# 
#         Returns:
#             The data stored on the Tree.
#         """
#         return self._data
# 
#     @property
#     def parent(self) -> Optional['Tree[T]']:
#         """
#         Provides the parent of the Tree. The property ensures it is readonly.
# 
#         Returns:
#             A pointer to the parent Tree reference. None if there is no parent.
#         """
#         return self._parent
# 
#     @overload
#     def __getitem__(self, key: int) -> 'Tree[T]':
#         pass
# 
#     @overload
#     def __getitem__(self, key: slice) -> List['Tree[T]']:
#         pass
# 
#     def __getitem__(self, key):
#         """
#         Get specific children from the Tree. This can be an integer or slice.
# 
#         Args:
#             key: The indexer for the item.
#         """
#         return self._children[key]
# 
#     def __iter__(self) -> Iterator['Tree[T]']:
#         """
#         Provides an iterator over the children.
#         """
#         for child in self._children:
#             yield child
# 
#     def __len__(self) -> int:
#         """
#         Provides the number of direct children on the tree.
# 
#         Returns:
#             The number of direct children on the tree.
#         """
#         return len(self._children)


# Path: pyconll/tree/_treebuilder.py
from typing import Any, Generic, TypeVar
from pyconll.tree.tree import Tree

    """
    A TreeBuilder is a utility to create arbitrary, immutable Trees. TreeBuilder
    works by traversing and creating a tree structure, and then providing an
    immutable view of the Tree on build. A TreeBuilder has an internal cursor
    on a Tree's node.

    A TreeBuilder can be reused to create many trees. This is useful if many
    similar Trees must be created. Note however, that if multiple Trees are
    created from the same TreeBuilder, Tree nodes will be unique, but data on
    the nodes will be shallow copies.
    """
    def __init__(self) -> None:
        """
        Creates a new empty TreeBuilder, with no internal data.
        """
        # Unfortunately, these must remain at Any since mypy cannot infer the
        # None check properly in _assert_initialization_status.
        self.root: Any = None
        self.current: Any = None
        self.constructed: bool = False

    def create_root(self, data: T) -> None:
        """
        Creates the root of the tree. This is the first step in Tree building.

        This should be called when a TreeBuilder is first created.

        Args:
            data: The optional data to put on the root node.
        """

        self.root = Tree(data)