boolean (final PsiMethodCallExpression methodCallExpression, final PsiElement usedImport, final PsiMethod psiMethod) { final boolean[] proceed = new boolean[]{true}; methodCallExpression.getContainingFile().accept(new JavaRecursiveElementWalkingVisitor() { @Override public void visitElement(@NotNull PsiElement element) { if (proceed[0]) { super.visitElement(element); } } @Override public void visitMethodCallExpression(@NotNull PsiMethodCallExpression expression) { super.visitMethodCallExpression(expression); if (expression == methodCallExpression) { return; } final PsiMethod resolved = expression.resolveMethod(); if (resolved == psiMethod) { proceed[0] = false; } else { final PsiElement resolveScope = expression.getMethodExpression().advancedResolve(false).getCurrentFileResolveScope(); if (resolveScope == usedImport) { proceed[0] = false; } } } }); return proceed[0]; }