def read_nodes(fh):
    """Read taxonomic nodes from a file.

    Parameters
    ----------
    fh : file handle
        Taxonomic nodes file.

    Returns
    -------
    dict
        Taxonomy tree.
    dict
        Taxonomic rank map.

    Notes
    -----
    Input file can be NCBI-style nodes.dmp or a plain map of ID to parent and
    (optional) rank.
    """
    tree, rankdic = {}, {}
    for line in fh:
        x = line.rstrip().replace('\t|', '').split('\t')
        tree[x[0]] = x[1]
        try:
            rankdic[x[0]] = x[2]
        except IndexError:
            pass
    return tree, rankdic