def findCommonParentGoIds(terms, go):
    """This function finds the common ancestors in the GO 
    tree of the list of terms in the input.

    :arg terms: a list of GO terms
    :type terms: tuple, list, :class:`~numpy.ndarray`

    :arg go: object containing a gene ontology (GO) directed acyclic graph (DAG)
    :type go: `~goatools.obo_parser.GODag`
    """
    rec = go[terms[0]]
    candidates = rec.get_all_parents()
    candidates.update({terms[0]})
    for term in terms[1:]:
        rec = go[term]
        parents = rec.get_all_parents()
        parents.update({term})
        candidates.intersection_update(parents)
    return candidates
