List<PsiClassType> (final PsiElement @NotNull [] elements) { final List<PsiClassType> array = new ArrayList<>(); final PsiElementVisitor visitor = new JavaRecursiveElementWalkingVisitor() { @Override public void visitElement(@NotNull PsiElement element) { addExceptions(array, getOwnUnhandledExceptions(element)); super.visitElement(element); } @Override public void visitLambdaExpression(@NotNull PsiLambdaExpression expression) { if (ArrayUtil.find(elements, expression) >= 0) { visitElement(expression); } } @Override public void visitMethodReferenceExpression(@NotNull PsiMethodReferenceExpression expression) { if (ArrayUtil.find(elements, expression) >= 0) { visitElement(expression); } } @Override public void visitClass(@NotNull PsiClass aClass) { } }; for (PsiElement element : elements) { element.accept(visitor); } return array; }