private static void addAnyOfNullSchema(ObjectNode node, SchemaGeneratorConfig config) {
        // cannot be sure what is specified in those other schema parts, instead simply create an anyOf wrapper
        ObjectNode nullSchema = config.createObjectNode()
                .put(config.getKeyword(SchemaKeyword.TAG_TYPE), config.getKeyword(SchemaKeyword.TAG_TYPE_NULL));
        String anyOfTagName = config.getKeyword(SchemaKeyword.TAG_ANYOF);
        // reduce likelihood of nested duplicate null schema
        JsonNode existingAnyOf = node.get(anyOfTagName);
        if (existingAnyOf instanceof ArrayNode) {
            Iterator<JsonNode> anyOfIterator = existingAnyOf.iterator();
            while (anyOfIterator.hasNext()) {
                if (nullSchema.equals(anyOfIterator.next())) {
                    // the existing anyOf array contains a duplicate null schema, remove it
                    anyOfIterator.remove();
                    // unlikely that there are multiple
                    break;
                }
            }
        }
        ArrayNode newAnyOf = config.createArrayNode()
                // one option in the anyOf should be null
                .add(nullSchema)
                // the other option is the given (assumed to be) not-nullable node
                .add(config.createObjectNode().setAll(node));
        // replace all existing (and already copied properties with the anyOf wrapper
        node.removeAll();
        node.set(anyOfTagName, newAnyOf);
    }
Preparation Step: combine the collected attributes and the javaType's definition in the given targetNode.

@param <M> type of target scope, i.e. either a field or method
@param targetNode node in the JSON schema that should represent the associated javaType and include the separately collected attributes
@param memberDetails details for field/method to populate schema for
@param collectedMemberAttributes separately collected attribute for the field/method in their respective declaring type
@see #populateFieldSchema(FieldScope)
jsonschema-generator/src/main/java/com/github/victools/jsonschema/generator/impl/SchemaGenerationContextImpl.java