private static NodeQuery buildNodeQuery(PathFinder.Path path) {
        NodeQuery query = new NodeQuery();
        // The path goes from trait definition -> shape with idRef
        for (Relationship relationship : path) {
            if (!relationship.getNeighborShape().isPresent()) {
                break;
            }
            switch (relationship.getRelationshipType()) {
                case MAP_KEY:
                    query.anyMemberName();
                    break;
                case MAP_VALUE:
                    query.anyMember();
                    break;
                case LIST_MEMBER:
                case SET_MEMBER:
                    query.anyElement();
                    break;
                case UNION_MEMBER:
                case STRUCTURE_MEMBER:
                    MemberShape member = (MemberShape) relationship.getNeighborShape().get();
                    query.member(member.getMemberName());
                    break;
                default:
                    // Other relationship types don't produce meaningful edges to search the node.
                    break;
            }
        }
        return query;
    }
Finds all {@link RelationshipType#ID_REF} relationships in a model.

<p>This works by finding all paths from {@link TraitDefinition} shapes
to shapes with {@link IdRefTrait}, then using those paths to search
the node values of each application of the trait to extract the {@link ShapeId}
value. Because we don't have a fixed set of traits known to potentially have
idRef members, this has to be done dynamically.
smithy-model/src/main/java/software/amazon/smithy/model/neighbor/IdRefShapeRelationships.java