PathElement[] (@NotNull TreeModel model, @NotNull TreePath treePath) { Object prev = null; int count = treePath.getPathCount(); PathElement[] result = new PathElement[count]; for (int i = 0; i < count; i++) { Object cur = treePath.getPathComponent(i); Object userObject = TreeUtil.getUserObject(cur); int childIndex = prev == null ? 0 : model.getIndexOfChild(prev, cur); result[i] = new PathElement(calcId(userObject), calcType(userObject), childIndex, userObject); prev = cur; } return result; }