int[] (TreePath path) { int[] result = new int[path.getPathCount()]; for (int i = 0; i < path.getPathCount(); i++) { TreeNode node = (TreeNode) path.getPathComponent(i); TreeNode parent = node.getParent(); result[i] = parent != null ? parent.getIndex(node) : 0; } return result; }