Next / Previous / Contents / Shipman's homepage

7.9. rank-parent: What taxon is the parent of a new taxon of a given rank?

When a new taxon is being added to the tree, this function describes the location of its parent node. When the tree is empty, as a special case the parent is signified by None. Otherwise, it is the last node in the path from the root node, through each last child, until we reach a a node that has a shallower depth than the new child but has either no children or children at that depth or below.

# rank-parent(taxaTree, rankCode) ==
#   if (taxaTree has no taxa) or
#   (taxaTree has no nodes with depth < rankCode's depth ->
#     None
#   else ->
#     the last (relative to preorder) node in taxaTree with
#     depth < rankCode's depth ]