public Subgraph findSubgraph(final String identifier, final boolean recursive) {

        Optional<Subgraph> toReturn = getSubgraphs().stream().filter(c -> c.getId().equals(identifier)).findFirst();
        if (!toReturn.isPresent() && recursive && getSubgraphs() != null && !getSubgraphs().isEmpty()) {

            // Does the Node with the given identifier exist in any Subgraph?
            toReturn = getSubgraphs().stream()
                    .map(c -> c.getStatements().findSubgraph(identifier, true))
                    .filter(c -> c != null)
                    .findFirst();
        }

        // All Done.
        return toReturn.orElse(null);
    }
public Subgraph findSubgraph(final String identifier, final boolean recursive) {

        Optional<Subgraph> toReturn = getSubgraphs().stream().filter(c -> c.getId().equals(identifier)).findFirst();
        if (!toReturn.isPresent() && recursive && getSubgraphs() != null && !getSubgraphs().isEmpty()) {

            
            toReturn = getSubgraphs().stream()
                    .map(c -> c.getStatements().findSubgraph(identifier, true))
                    .filter(c -> c != null)
                    .findFirst();
        }

        
        return toReturn.orElse(null);
    }
public Subgraph findSubgraph ( final String identifier , final boolean recursive ) { Optional < Subgraph > toReturn = getSubgraphs ( ) . stream ( ) . filter ( c -> c . getId ( ) . equals ( identifier ) ) . findFirst ( ) ; if ( ! toReturn . isPresent ( ) && recursive && getSubgraphs ( ) != null && ! getSubgraphs ( ) . isEmpty ( ) ) { // Does the Node with the given identifier exist in any Subgraph? toReturn = getSubgraphs ( ) . stream ( ) . map ( c -> c . getStatements ( ) . findSubgraph ( identifier , true ) ) . filter ( c -> c != null ) . findFirst ( ) ; } // All Done. return toReturn . orElse ( null ) ; }
Finds the Subgraph with the supplied identifier within this Statements (and within any contained Subgraphs, if
the {@code recursive} flag is true).

@param identifier The identifier to match against the {@link Subgraph#getId()} of a matching Node.
@param recursive  If {@code true}, the search should recurse into the Statements of Subgraphs.
@return The Subgraph with the supplied identifier - or null if none was found.
Finds the Subgraph with the supplied identifier within this Statements ( and within any contained Subgraphs if the { @code recursive } flag is true ) .