# skbio.core.tree.TreeNode.ancestors¶

TreeNode.ancestors()[source]

Returns 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.core.tree import TreeNode
>>> tree = TreeNode.from_newick("((a,b)c,(d,e)f)root;")
>>> [node.name for node in tree.find('a').ancestors()]
['c', 'root']