void (@NotNull Collection<? extends Usage> usages) { Usage toSelect = getNextToSelect(usages); UsageNode nodeToSelect = toSelect != null ? myUsageNodes.get(toSelect) : null; Set<UsageNode> nodes = usagesToNodes(usages.stream()).collect(Collectors.toSet()); usages.forEach(myUsageNodes::remove); if (!myUsageNodes.isEmpty()) { Set<UsageInfo> mergedInfos = usages.stream() .filter(usage -> usage instanceof UsageInfo2UsageAdapter && ((UsageInfo2UsageAdapter)usage).getMergedInfos().length > 1) .flatMap(usage -> Arrays.stream(((UsageInfo2UsageAdapter)usage).getMergedInfos())) .collect(Collectors.toSet()); if (!mergedInfos.isEmpty()) { myUsageNodes.keySet().removeIf( usage -> usage instanceof UsageInfo2UsageAdapter && mergedInfos.contains(((UsageInfo2UsageAdapter)usage).getUsageInfo())); } } if (!nodes.isEmpty() && !myPresentation.isDetachedMode()) { UIUtil.invokeLaterIfNeeded(() -> { if (isDisposed()) return; DefaultTreeModel treeModel = (DefaultTreeModel)myTree.getModel(); ((GroupNode)treeModel.getRoot()).removeUsagesBulk(nodes, treeModel); if (nodeToSelect != null) { TreePath path = new TreePath(nodeToSelect.getPath()); myTree.addSelectionPath(path); } }); } }