def load_nodes(nodes_dmp, wanted_ranks=None):
    """Load the NCBI taxdump nodes.dmp file.

    Returns two dicts, the parent/child relationships, and the ranks (values
    are lists of taxids).

    Default is all ranks, can provide a possibly empty list/set of ranks of
    interest.
    """
    tree = {}
    ranks = {}  # keys are rank names, values are lists of ids
    with open(nodes_dmp) as handle:
        for line in handle:
            parts = line.split("\t|\t", 3)
            taxid = int(parts[0].strip())
            parent = int(parts[1].strip())
            rank = parts[2].strip()
            tree[taxid] = parent
            if wanted_ranks is None or rank in wanted_ranks:
                try:
                    ranks[rank].append(taxid)
                except KeyError:
                    ranks[rank] = [taxid]
    return tree, ranks