protected static Object traverseTree(TreeNode<?> node, AtomicInteger rowIndex) {

        int index = rowIndex.get();
        rowIndex.decrementAndGet();
        if (index <= 0) {
            return node.getData();
        }

        if (node.getChildren() != null) {
            Object data = null;
            for (TreeNode childNode : node.getChildren()) {
                data = traverseTree(childNode, rowIndex);
                if (data != null) {
                    break;
                }
            }
            return data;
        }
        else {
            return null;
        }

    }
Traverses a tree and visits all children until it finds the one with row index i

@param node
@param rowIndex
@return data of found treenode
primefaces/src/main/java/org/primefaces/component/treetable/export/TreeTableExporter.java