class DependencyGraph {

    public Stream<T> getBuildChain() throws CycleDetectedException {
        DefaultDirectedGraph<T, DefaultEdge> graph = builder.build();
        ensureNoCycle(graph);
        return Iterators.toStream(new TopologicalOrderIterator<>(graph));
    }

    public  DependencyGraph(Function<T, Optional<T>> getParent);

}