def reduce_func(db, funclist, sep):
    """
    Take a set of functional terms and return only the
     terms that are not the ancestor of any
    other term in the set.

    :param db: reference database
    :param funclist: string that contains functional terms separated by <sep>
    :param sep: character separating the terms in the list
    :return:
    """
    split = set(funclist.split(sep))
    reduced = split.copy()
    for goid in split:
        ancestors = db.get_ancestors(goid)
        reduced.difference_update(ancestors)
    pasted = sep.join(reduced)
    return pasted