TreePath (TreePath treePath) { TreeNode treeNode = (TreeNode)treePath.getLastPathComponent(); if (treeNode instanceof MessageNode) { AntBuildMessageView.MessageType type = ((MessageNode)treeNode).getType(); if (type == AntBuildMessageView.MessageType.ERROR) { return treePath; } } if (treeNode.getChildCount() == 0) { return null; } for (int i = 0; i < treeNode.getChildCount(); i++) { TreeNode childNode = treeNode.getChildAt(i); TreePath childPath = treePath.pathByAddingChild(childNode); TreePath usagePath = getFirstErrorPath(childPath); if (usagePath != null) { return usagePath; } } return null; }