private void traverseUp(Shape current, Path path, Set<ShapeId> visited) {
            if (path != null && current.getId().equals(startingShape.getId())) {
                // Add the path to the result set if the target shape was reached.
                // But, don't add the path if no nodes have been traversed.
                results.add(path);
                return;
            }

            // Short-circuit recursion.
            if (visited.add(current.getId())) {
                for (Relationship relationship : provider.getNeighbors(current)) {
                    if (relationship.getDirection() == RelationshipDirection.DIRECTED) {
                        if (filter.test(relationship)) {
                            traverseUp(relationship.getShape(), new Path(relationship, path), visited);
                        }
                    }
                }
                // Let the less recursive addition remove the entry from the set.
                visited.remove(current.getId());
            }
        }
Converts the path to valid {@link Selector} syntax.

@return Returns the path as a selector.
smithy-model/src/main/java/software/amazon/smithy/model/selector/PathFinder.java