def build_sp2age(sptree, seed):
    """Build a species to age dictionary given a tree and its main seq.

    Parameters
    ----------
    sptree : tree
        Phylogenetic tree of interest
    seed : str
        Main seq where the dictionary will start.

    Returns
    -------
    type
        Returns a dict with species:age_to_main as key:value

    """
    spe2age = {}
    node = sptree.get_leaves_by_name(seed)[0]
    age = 1
    while not node.is_root():
        for leaf in node.get_leaves():
            if leaf.name not in spe2age:
                spe2age[leaf.name] = age
        age += 1
        node = node.up
    for leaf in sptree.get_leaves():
        if leaf.name not in spe2age:
            spe2age[leaf.name] = age
    return spe2age