def procedure_prune(ast, entries):
    needed = set(entries)

    # First, figure out which procedures we actually need by determining
    # the free variables in each of the entry points
    for p in ast:
        needed.update(S.free_variables(p.body()))

    # Now, only keep top-level procedures that have been referenced
    return [p for p in ast if p.name().id in needed]
dataset/ETHPy150Open bryancatanzaro/copperhead/copperhead/compiler/rewrites.py/procedure_prune/original