boolean (@NotNull PsiClass targetClass) { if (!targetClass.hasModifierProperty(PsiModifier.PRIVATE)) return false; PsiFile file = targetClass.getContainingFile(); if (file == null) return false; LocalSearchScope scope = new LocalSearchScope(file); return ReferencesSearch.search(targetClass, scope).forEach(new Processor<>() { int count = 0; @Override public boolean process(PsiReference reference) { return ++count < 2; } }); }