PsiMethod (PsiMethodCallExpression mapCall) { final PsiMethodCallExpression candidateToRemove = findCandidateToRemove(mapCall); if (candidateToRemove == null) return null; final PsiType type = StreamApiUtil.getStreamElementType(mapCall.getType()); if (type == null) return null; final PsiMethod resolvedCandidateToRemove = candidateToRemove.resolveMethod(); if (resolvedCandidateToRemove == null) return null; final PsiType candidateToRemoveType = resolvedCandidateToRemove.getReturnType(); if (candidateToRemoveType == null) return null; if (!type.equals(candidateToRemoveType) && !candidateToRemoveType.equals(PsiPrimitiveType.getUnboxedType(type))) return null; return resolvedCandidateToRemove; }