private Supplier<ObjectNode> mergeSchemas(ObjectNode mainNodeIncludingAllOf, List<JsonNode> nodes, Map<String, SchemaKeyword> reverseKeywordMap) {
        if (nodes.stream().anyMatch(part -> part.isBoolean() && !part.asBoolean())) {
            return null;
        }
        List<ObjectNode> parts = nodes.stream()
                .filter(ObjectNode.class::isInstance)
                .map(ObjectNode.class::cast)
                .collect(Collectors.toList());

        // collect all defined attributes from the separate parts and check whether there are incompatible differences
        Map<String, List<JsonNode>> fieldsFromAllParts = this.getFieldsFromAllParts(parts);
        if (this.shouldSkipMergingAllOf(mainNodeIncludingAllOf, parts, fieldsFromAllParts)) {
            return null;
        }
        Map<String, List<JsonNode>> unsupportedTagValues = fieldsFromAllParts.entrySet().stream()
                .filter(entry -> !reverseKeywordMap.containsKey(entry.getKey()))
                .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, SchemaCleanUpUtils::throwingMerger, LinkedHashMap::new));
        if (unsupportedTagValues.values().stream().anyMatch(occurrences -> occurrences.size() > 1)) {
            // unsupported tag with more than one occurrence: be conservative and don't merge
            return null;
        }
        Map<SchemaKeyword, Supplier<? extends JsonNode>> supportedTagValueSuppliers = this.collectSupportedTagValueSuppliers(fieldsFromAllParts,
                reverseKeywordMap, mainNodeIncludingAllOf);
        if (supportedTagValueSuppliers == null) {
            // unable to merge the values for some keyword; abort merge
            return null;
        }
        // all attributes are either distinct or have equal values in all occurrences
        return () -> {
            ObjectNode mergedNode = this.config.createObjectNode();
            // for the supported tags, there may be multiple occurrences that requiring individual merging
            supportedTagValueSuppliers.forEach((keyword, valueSupplier) -> mergedNode.set(this.config.getKeyword(keyword), valueSupplier.get()));
            // for the unsupported tags, there is only a single occurrence each
            unsupportedTagValues.forEach((tagName, valueList) -> mergedNode.set(tagName, valueList.get(0)));
            return mergedNode;
        };
    }
Determine whether a given list of sub-schema nodes can be merged into a single schema node. If yes, providing a supplier that performs the
actual consolidation once called.

@param mainNodeIncludingAllOf the node containing the "allOf" tag to be merged (may be {@code null} if all nodes have the same weight)
@param nodes full list of nodes to consider merging (including optional "mainNodeIncludingAllOf")
@param reverseKeywordMap look-up map from tag's name in given node to the known keyword it represents (passed in for improved performance)
@return supplier of the successfully merged schemas (into a new node) or {@code null} if merging the given nodes is not easily possible
jsonschema-generator/src/main/java/com/github/victools/jsonschema/generator/impl/SchemaCleanUpUtils.java