def transitive_closure(roots, successors) ->set:
    """ Transitive closure is a simple unordered graph exploration. """
    black = set()
    grey = set(roots)
    while grey:
        k = grey.pop()
        if k not in black:
            black.add(k)
            them = successors(k)
            if them is not None:
                grey.update(them)
    return black
