private Optional<Node> createMetadata(Model model) {
        // Grab metadata, filter by key using the predicate.
        Map<StringNode, Node> metadata = model.getMetadata()
                .entrySet()
                .stream()
                .filter(entry -> metadataFilter.test(entry.getKey()))
                .collect(Collectors.toMap(entry -> Node.from(entry.getKey()), Map.Entry::getValue));
        return metadata.isEmpty() ? Optional.empty() : Optional.of(new ObjectNode(metadata, SourceLocation.NONE));
    }
Serializes a {@link Model} to an {@link ObjectNode}.

<p>The serialized value sorts all map key-value pairs so that they contain
a consistent key ordering, reducing noise in diffs based on
serialized model.

<p>After serializing to an ObjectNode, the node can then be serialized
to formats like JSON, YAML, Ion, etc.
smithy-model/src/main/java/software/amazon/smithy/model/shapes/ModelSerializer.java