Condition<PsiElement> (PsiMethod constructor, Collection<PsiReference> originalReferences, @NotNull List<? super UsageInfo> usages, PsiElement[] allElementsToDelete) { if (isTheOnlyEmptyDefaultConstructor(constructor)) return null; Set<PsiMethod> newConstructors = new HashSet<>(); newConstructors.add(constructor); Map<PsiMethod, Collection<PsiReference>> constructorsToRefs = new HashMap<>(); constructorsToRefs.put(constructor, originalReferences); HashSet<PsiMethod> passConstructors = new HashSet<>(); do { passConstructors.clear(); for (PsiMethod method : newConstructors) { Collection<PsiReference> references = constructorsToRefs.get(method); for (PsiReference reference : references) { PsiMethod overridingConstructor = getOverridingConstructorOfSuperCall(reference.getElement()); if (overridingConstructor != null && !constructorsToRefs.containsKey(overridingConstructor)) { Collection<PsiReference> overridingConstructorReferences = ReferencesSearch.search(overridingConstructor).findAll(); constructorsToRefs.put(overridingConstructor, overridingConstructorReferences); passConstructors.add(overridingConstructor); } } } newConstructors.clear(); newConstructors.addAll(passConstructors); } while(!newConstructors.isEmpty()); Set<PsiMethod> validOverriding = validateOverridingMethods(constructor, originalReferences, constructorsToRefs.keySet(), constructorsToRefs, usages, allElementsToDelete); return usage -> { if(usage instanceof PsiFile) return false; return isInside(usage, allElementsToDelete) || isInside(usage, validOverriding); }; }