void (@NotNull AnActionEvent e) { Presentation presentation = e.getPresentation(); presentation.setEnabled(false); final TreePath[] selectionPath = myTree.getSelectionPaths(); if (selectionPath == null) { return; } if (myCondition != null) { Object[] result = new Object[selectionPath.length]; for (int i = 0; i < selectionPath.length; i++) { result[i] = selectionPath[i].getLastPathComponent(); } if (!myCondition.test(result)) { return; } } presentation.setEnabled(true); }