private Set<String> findAllRefs(ObjectNode node) {
        return node.accept(new NodeVisitor.Default<Set<String>>() {
            @Override
            protected Set<String> getDefault(Node node) {
                return SetUtils.of();
            }

            @Override
            public Set<String> arrayNode(ArrayNode node) {
                Set<String> result = new HashSet<>();
                for (Node member : node.getElements()) {
                    result.addAll(member.accept(this));
                }
                return result;
            }

            @Override
            public Set<String> objectNode(ObjectNode node) {
                Set<String> result = new HashSet<>();

                if (node.getMember("$ref").isPresent()) {
                    node.getMember("$ref")
                            .flatMap(Node::asStringNode)
                            .map(StringNode::getValue)
                            .ifPresent(result::add);
                } else {
                    for (Node member : node.getMembers().values()) {
                        result.addAll(member.accept(this));
                    }
                }

                return result;
            }
        });
    }
Removes unused components from the OpenAPI model.

<p>This plugin will take effect by default, but can be disabled by setting
"openapi.keepUnusedComponents" to true. Refs are removed in rounds until
a round of removals has no effect.

<p>TODO: This plugin currently only supports the removal of schemas and security schemes.
smithy-openapi/src/main/java/software/amazon/smithy/openapi/fromsmithy/mappers/RemoveUnusedComponents.java