scikit-bio is back in active development! Check out our announcement of revitalization.

skbio.tree.TreeNode.ancestors#

TreeNode.ancestors()[source]#

Return all ancestors back to the root.

This call will return all nodes in the path back to root, but does not include the node instance that the call was made from.

Returns:
list of TreeNode

The path, toward the root, from self

Examples

>>> from skbio import TreeNode
>>> tree = TreeNode.read(["((a,b)c,(d,e)f)root;"])
>>> [node.name for node in tree.find('a').ancestors()]
['c', 'root']