void (@NotNull AnActionEvent e) { TreePath path = myTree.getSelectionPath(); boolean enabled = path != null && path.getPathCount() > (myTree.isRootVisible() ? 1 : 2); Object component = myTree.getLastSelectedPathComponent(); if (enabled && component instanceof XValueNodeImpl) { enabled = !((XValueNodeImpl)component).isLeaf(); } e.getPresentation().setEnabled(enabled); }