private void updateNullableReferences(List<ObjectNode> nullableReferences, DefinitionCollectionDetails definitionCollectionDetails,
            String nonNullableReferenceKey, Map.Entry<DefinitionKey, String> baseReferenceKey) {
        DefinitionKey definitionKey = baseReferenceKey.getKey();
        ObjectNode definition;
        if (nonNullableReferenceKey == null) {
            definition = this.generationContext.getDefinition(definitionKey);
        } else {
            definition = this.config.createObjectNode().put(this.config.getKeyword(SchemaKeyword.TAG_REF), nonNullableReferenceKey);
        }
        this.generationContext.makeNullable(definition);
        if (this.shouldCreateNullableDefinition(this.generationContext, definitionKey, nullableReferences)) {
            String nullableDefinitionName = this.definitionNamingStrategy
                    .adjustNullableName(definitionKey, baseReferenceKey.getValue(), this.generationContext);
            definitionCollectionDetails.getDefinitionsNode().set(nullableDefinitionName, definition);
            nullableReferences.forEach(node -> node.put(this.config.getKeyword(SchemaKeyword.TAG_REF),
                    definitionCollectionDetails.getReferenceKey(nullableDefinitionName)));
        } else {
            nullableReferences.forEach(node -> AttributeCollector.mergeMissingAttributes(node, definition));
        }
    }
Finalisation Step: collect the entries for the generated schema's "definitions" and ensure that all references are either pointing to the
appropriate definition or contain the respective (sub) schema directly inline.

@param referenceKeyPrefix designated prefix to the entries in the returned definitions node (i.e., on {@link SchemaKeyword#TAG_REF} values)
@param mainSchemaKey definition key identifying the main type for which createSchemaReference() was invoked
@return node representing the main schema's "definitions" (may be empty)
jsonschema-generator/src/main/java/com/github/victools/jsonschema/generator/SchemaBuilder.java