boolean (@NotNull PsiElement explored, @NotNull PsiMember place) { if (explored instanceof PsiNamedElement) { final String name = ((PsiNamedElement)explored).getName(); if (name != null && PsiSearchHelper.getInstance(explored.getProject()) .isCheapEnoughToSearch(name, GlobalSearchScope.projectScope(explored.getProject()), null, null) == PsiSearchHelper.SearchCostResult.TOO_MANY_OCCURRENCES) { return false; } } if (explored instanceof PsiClassOwner) { for (PsiClass aClass : ((PsiClassOwner)explored).getClasses()) { if (!usedOnlyIn(aClass, place)) return false; } return true; } if (UnusedDeclarationInspectionBase.isDeclaredAsEntryPoint(explored)) return false; CommonProcessors.FindProcessor<PsiReference> findProcessor = new CommonProcessors.FindProcessor<>() { @Override protected boolean accept(PsiReference reference) { final PsiElement element = reference.getElement(); return !PsiTreeUtil.isAncestor(place, element, true) && !PsiTreeUtil.isAncestor(explored, element, true); } }; return ReferencesSearch.search(explored).forEach(findProcessor); }