PsiMethod[] (PsiMethod[] methods, PsiElement[] allElementsToDelete) { ArrayList<PsiMethod> list = new ArrayList<>(); for (PsiMethod method : methods) { boolean isDeleted = false; for (PsiElement element : allElementsToDelete) { if (element == method) { isDeleted = true; break; } } if (!isDeleted) { list.add(method); } } return list.toArray(PsiMethod.EMPTY_ARRAY); }