Usage (@NotNull Usage toDelete) { ThreadingAssertions.assertEventDispatchThread(); UsageNode usageNode = myUsageNodes.get(toDelete); if (usageNode == null || usageNode.getParent().getChildCount() == 0) return null; DefaultMutableTreeNode node = myRootPanel.mySupport.findNextNodeAfter(myTree, usageNode, true); if (node == null) node = myRootPanel.mySupport.findNextNodeAfter(myTree, usageNode, false); // last node return node == null ? null : node.getUserObject() instanceof Usage ? (Usage)node.getUserObject() : null; }