List<UsageInfo> (List<? extends UsageInfo> infos) { Map<PsiElement, MoveRenameUsageInfo> moveRenameInfos = new LinkedHashMap<>(); Set<PsiElement> usedElements = new HashSet<>(); List<UsageInfo> result = new ArrayList<>(infos.size() / 2); for (UsageInfo info : infos) { LOG.assertTrue(info != null); PsiElement element = info.getElement(); if (info instanceof MoveRenameUsageInfo) { if (usedElements.contains(element)) continue; moveRenameInfos.put(element, (MoveRenameUsageInfo)info); } else { moveRenameInfos.remove(element); usedElements.add(element); if (!(info instanceof PossiblyIncorrectUsage) || ((PossiblyIncorrectUsage)info).isCorrect()) { result.add(info); } } } result.addAll(moveRenameInfos.values()); return result; }