TreeNode[] (TreeNode aNode, int depth) { TreeNode[] retNodes; if (aNode == null) { if (depth == 0) { return null; } else { retNodes = new TreeNode[depth]; } } else { depth++; if (aNode == myRoot) { retNodes = new TreeNode[depth]; } else { retNodes = getPathToRoot(aNode.getParent(), depth); } retNodes[retNodes.length - depth] = aNode; } return retNodes; }