class TransitiveClosure {

    public static TransitiveClosure getUpstreamVerticesForCollection(List<Vertex> vertices, boolean includeNonProbabilistic) {

        Predicate<Vertex> shouldAdd = includeNonProbabilistic ? ADD_ALL : PROBABILISTIC_OR_OBSERVED_ONLY;

        Set<Vertex> upstreamVertices = getVertices(
            vertices,
            Vertex::getParents,
            v -> false,
            shouldAdd
        );

        return new TransitiveClosure(upstreamVertices);
    }

    private  TransitiveClosure(Set<Vertex> allVertices);

}