boolean () { TreePath path = myTree.getSelectionPath(); if (path == null) { return false; } DefaultMutableTreeNode node = (DefaultMutableTreeNode)path.getLastPathComponent(); Object userObject = node.getUserObject(); if (userObject == null) { return false; } if (userObject instanceof NodeDescriptor && ((NodeDescriptor<?>)userObject).getElement() instanceof TodoItemNode) { return myTree.getRowCount() != myTree.getRowForPath(path) + 1; } else { TreeModel model = myTree.getModel(); return !model.isLeaf(node); } }