void ( Set<PsiMethod> privateMethods, HashMap<PsiMethod, Collection<PsiReference>> referenceMap) { final Set<PsiMethod> remainingMethods = new HashSet<>(privateMethods); boolean stabilized = false; while (!stabilized) { ProgressManager.checkCanceled(); stabilized = true; final Set<PsiMethod> methodsDeterminedThisPass = new HashSet<>(); for (PsiMethod method : remainingMethods) { ProgressManager.checkCanceled(); final Collection<PsiReference> references = referenceMap.get(method); for (PsiReference reference : references) { ProgressManager.checkCanceled(); if (isKnownToBeUsed(reference)) { usedMethods.add(method); methodsDeterminedThisPass.add(method); stabilized = false; } } } remainingMethods.removeAll(methodsDeterminedThisPass); } unusedMethods.addAll(remainingMethods); }