public List<Shape> getShapes() {
            List<Shape> results = new ArrayList<>(size());
            Iterator<Relationship> iterator = iterator();
            for (int i = 0; i < size(); i++) {
                Relationship rel = iterator.next();
                results.add(rel.getShape());
                // Add the shape pointed to by the tail to the result set if present
                // without need to get the tail after iterating (an O(N) operation).
                if (i == size() - 1) {
                    rel.getNeighborShape().ifPresent(results::add);
                }
            }
            return results;
        }
Gets a list of all shapes in the path including the starting
shape all the way to the last shape.

<p>The returned list does not return the last element (the
end shape targeted by the last neighbor) if it does not exist.

@return Returns the list of shapes.
smithy-model/src/main/java/software/amazon/smithy/model/selector/PathFinder.java