private static List<Fragment> fragmentsForUnvisitedNodes(Map<NodeId, Node> allNodes, Collection<Node> connectedNodes) {
        List<Fragment> subplan = new LinkedList<>();

        Set<Node> nodeWithFragment = connectedNodes.stream()
                // make sure the fragment either has no dependency or dependencies have been dealt with
                .filter(node -> !node.getFragmentsWithoutDependency().isEmpty() ||
                        !node.getFragmentsWithDependencyVisited().isEmpty())
                .collect(Collectors.toSet());
        while (!nodeWithFragment.isEmpty()) {
            nodeWithFragment.forEach(node -> subplan.addAll(nodeToPlanFragments(node, allNodes, false)));
            nodeWithFragment = connectedNodes.stream()
                    .filter(node -> !node.getFragmentsWithoutDependency().isEmpty() ||
                            !node.getFragmentsWithDependencyVisited().isEmpty())
                    .collect(Collectors.toSet());
        }

        return subplan;
    }
private static List < Fragment > fragmentsForUnvisitedNodes ( Map < NodeId , Node > allNodes , Collection < Node > connectedNodes ) { List < Fragment > subplan = new LinkedList < > ( ) ; Set < Node > nodeWithFragment = connectedNodes . stream ( ) . filter ( node -> ! node . getFragmentsWithoutDependency ( ) . isEmpty ( ) || ! node . getFragmentsWithDependencyVisited ( ) . isEmpty ( ) ) . collect ( Collectors . toSet ( ) ) ; while ( ! nodeWithFragment . isEmpty ( ) ) { nodeWithFragment . forEach ( node -> subplan . addAll ( nodeToPlanFragments ( node , allNodes , false ) ) ) ; nodeWithFragment = connectedNodes . stream ( ) . filter ( node -> ! node . getFragmentsWithoutDependency ( ) . isEmpty ( ) || ! node . getFragmentsWithDependencyVisited ( ) . isEmpty ( ) ) . collect ( Collectors . toSet ( ) ) ; } return subplan ; }
add unvisited node fragments to plan