private void removeUsagesAndSelectNext(@NotNull Collection<? extends Usage> usages, @NotNull Collection<? extends Usage> excluded) {
    final List<Usage> sortedUsages = myUsageView.getSortedUsages();
    if (sortedUsages.size() == usages.size()) {
      myUsageView.close();
    }
    else {
      Usage firstValid = null;
      Usage select = null;
      for (Usage usage : sortedUsages) {
        if (usages.contains(usage)) {
          select = null;
          continue;
        }
        if (excluded.contains(usage) || !isValid((UsageInfo2UsageAdapter)usage)) {
          continue;
        }
        if (select == null) {
          select = usage;
        }
        if (firstValid == null) {
          firstValid = usage;
        }
      }
      myUsageView.removeUsagesBulk(usages);
      myUsageView.selectUsages(new Usage[]{
        ObjectUtils.coalesce(select, firstValid, myUsageView.getSortedUsages().get(0))
      });
    }
  }
private void removeUsagesAndSelectNext(@NotNull Collection<? extends Usage> usages, @NotNull Collection<? extends Usage> excluded)