def recurse_taxonomy_map(tax_id_map, tax_id, parent=False):
    """
    Takes the output dict from make_taxonomy_map and an input tax_id
    and recurses either up or down through the tree to get /all/ children
    (or parents) of the given tax_id.
    """

    if parent:
        # TODO: allow filtering on tax_id and its parents, too
        pass
    else:

        def _child_recurse(tax_id, visited):
            try:
                children = [tax_id] + list(tax_id_map[tax_id])
            except KeyError:
                children = [tax_id]

            for child in children:
                if child not in visited:
                    visited.append(child)
                    children.extend(_child_recurse(child, visited))

            return children

        return list(set(_child_recurse(tax_id, [])))
Takes the output dict from make_taxonomy_map and an input tax_id
    and recurses either up or down through the tree to get /all/ children
    (or parents) of the given tax_id.