the sequence of integers corresponding to a node's position in a tree
The depth of the position in the tree.
The depth of the position in the tree.
i.e. the depth of the root is zero, the depth of the root's children is one, etc.
Gets the kth child of this position.
Gets the kth child of this position.
the number of the desired child (counting from zero)
the child's position
Returns whether the specified position is a descendant of this position.
Returns whether the specified position is a descendant of this position.
This returns true if the argument position is the same as this position (i.e. a position is considered by this function to be its own descendant).
the position of interest
whether the specified position is a descendant of this position
Gets the parent of this position (if it exists).
Gets the parent of this position (if it exists).
This returns None if this is the root position.
A Position is a essentially a pointer to a node in a rooted, directed tree. It is a sequence of non-negative integers.
It is probably easiest to describe the concept by example. The root of the tree is the empty sequence. The first child of the root is Seq(0) (we count from zero). The third child of the first child of the root is Seq(2, 0). The seventh child of the third child of the first child of the root is Seq(6, 2, 0). Etc.
the sequence of integers corresponding to a node's position in a tree