private boolean checkReferences(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;
    }
private boolean checkReferences(PsiNamedElement namedElement)