public Optional<Schema> getDefinition(String pointer) {
        String unescaped = NodePointer.unescape(pointer);

        // Attempt to get the unescaped pointer, as-is.
        if (definitions.containsKey(unescaped)) {
            return Optional.ofNullable(definitions.get(unescaped));
        }

        List<String> pointerParts = NodePointer.parse(pointer).getParts();

        // An empty pointer returns the root schema.
        if (pointerParts.isEmpty()) {
            return Optional.of(getRootSchema());
        }

        // Compute the part of the pointer that points at a literal entry in
        // the map of definitions, and then compute the remaining pointer
        // segments that need to be used when retrieving a nested schema.
        String prefix = pointer.startsWith("#") ? "#" : "";
        for (int position = 0; position < pointerParts.size(); position++) {
            String part = pointerParts.get(position);
            prefix += '/' + part;
            if (definitions.containsKey(prefix)) {
                List<String> remaining = pointerParts.subList(position + 1, pointerParts.size());
                String[] suffix = remaining.toArray(new String[0]);
                return definitions.get(prefix).selectSchema(suffix);
            }
        }

        return Optional.empty();
    }
Gets a schema definition from the "definitions" map using a JSON pointer.

<p>The "root" schema is returned if {@code pointer} is an empty string.

@param pointer JSON Schema pointer to retrieve.
@return Returns the optionally found schema definition.
smithy-jsonschema/src/main/java/software/amazon/smithy/jsonschema/SchemaDocument.java