Tree is a very basic immutable tree class. A Tree can have multiple children and has one parent. The parent and child of a tree are established when a Tree is created. Accessing the data on a Tree can be done through the data member. A Tree is created through the TreeBuilder module which is an internal API in pyconll. A Tree’s use in pyconll is when creating a Tree structure from a Sentence object in the sentencetree module.


A general immutable tree module. This module is used when parsing a serial sentence into a Tree structure.

class pyconll.tree.tree.Tree[source]

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.


Get specific children from the Tree. This can be an integer or slice.

Parameters:key – The indexer for the item.

Create a new empty tree. To create a useful Tree, use TreeBuilder.


Provides an iterator over the children.


Provides the number of direct children on the tree.

Returns:The number of direct children on the tree.

The data on the tree node. The property ensures it is readonly.

Returns:The data stored on the Tree. No data is represented as None.

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.