public List<TreeCursor> getPathToCursor() {
        List<TreeCursor> path = new ArrayList<>();
        TreeCursor current = this;
        do {
            path.add(current);
            current = current.parent;
        } while (current != null);
        Collections.reverse(path);
        return path;
    }
Get a list of tree cursors that lead up to the current tree, starting from the root as the first element, and
including the current tree as the last element.

@return Returns the path to the current tree from the root.
smithy-syntax/src/main/java/software/amazon/smithy/syntax/TreeCursor.java