hollow/src/main/java/com/netflix/hollow/tools/traverse/TransitiveSetTraverser.java
public static void removeReferencedOutsideClosure(HollowReadStateEngine stateEngine, Map<String, BitSet> matches) {
        List<HollowSchema> orderedSchemas = HollowSchemaSorter.dependencyOrderedSchemaList(stateEngine);
        Collections.reverse(orderedSchemas);


        for(HollowSchema referencedSchema : orderedSchemas) {
            if(matches.containsKey(referencedSchema.getName())) {
                for(HollowSchema referencerSchema : orderedSchemas) {
                    if(referencerSchema == referencedSchema)
                        break;

                    if(matches.containsKey(referencedSchema.getName()) && matches.get(referencedSchema.getName()).cardinality() > 0)
                        traverseReferencesOutsideClosure(stateEngine, referencerSchema.getName(), referencedSchema.getName(), matches, REMOVE_REFERENCED_OUTSIDE_CLOSURE);
                }
            }
        }
    }
public static void removeReferencedOutsideClosure(HollowReadStateEngine stateEngine, Map<String, BitSet> matches) {
        List<HollowSchema> orderedSchemas = HollowSchemaSorter.dependencyOrderedSchemaList(stateEngine);
        Collections.reverse(orderedSchemas);


        for(HollowSchema referencedSchema : orderedSchemas) {
            if(matches.containsKey(referencedSchema.getName())) {
                for(HollowSchema referencerSchema : orderedSchemas) {
                    if(referencerSchema == referencedSchema)
                        break;

                    if(matches.containsKey(referencedSchema.getName()) && matches.get(referencedSchema.getName()).cardinality() > 0)
                        traverseReferencesOutsideClosure(stateEngine, referencerSchema.getName(), referencedSchema.getName(), matches, REMOVE_REFERENCED_OUTSIDE_CLOSURE);
                }
            }
        }
    }
Remove any records from the given selection which are referenced by other records not in the selection.
@param stateEngine the state engine
@param matches the matches