void (LookupElement key, @NotNull MultiMap<LookupElement, LookupElement> mainMap, @NotNull MultiMap<LookupElement, LookupElement> inverseMap) { Collection<LookupElement> removed = mainMap.remove(key); if (removed == null) return; for (LookupElement reference : new ArrayList<>(removed)) { inverseMap.remove(reference, key); } }