Take a look at the following steps:

- First, let's load the RAxML-generated tree for all Ebola viruses, as follows:

import dendropyebola_raxml = dendropy.Tree.get_from_path('my_ebola.nex', 'nexus')

- Then, we need to compute the level of each node (the distance to the root node):

def compute_level(node, level=0): for child in node.child_nodes(): compute_level(child, level + 1) if node.taxon is not None: print("%s: %d %d" % (node.taxon, node.level(), level))compute_level(ebola_raxml.seed_node)

DendroPy's node representation has a level method (which is used for comparison), but the point here is to introduce a recursive algorithm, so we will implement it anyway.

Note how the function works; it's called with the `seed_node` (which ...