import networkx


def get_superterms(term, hpo_g):
    """
    Get all HPO terms upstream of a query term
    """

    if hpo_g.nodes.get(term, None) is not None:
        superterms = networkx.descendants(hpo_g, term)
        superterms = [s for s in superterms if s is not None]
    else:
        superterms = []

    return superterms