boolean (PsiNamedElement namedElement) { final PsiFile containingFile = namedElement.getContainingFile(); if (!isOnTheFly() || isCheapToSearchInFile(namedElement)) { return ReferencesSearch.search(namedElement, GlobalSearchScope.fileScope(containingFile)) .anyMatch(ref -> isRequiredObsoleteCollectionElement(ref.getElement())); } return true; }