void (PsiMethodCallExpression call) { PsiMethodCallExpression subsequentCall = findSubsequentCall(call, CALLS_USELESS_FOR_SINGLE_ELEMENT_STREAM::contains, name -> STANDARD_STREAM_INTERMEDIATE_OPERATIONS.contains(name) && !name.startsWith("flatMap")); if (subsequentCall != null) { register(subsequentCall, JavaBundle.message("inspection.redundant.stream.optional.call.explanation.at.most.one")); return; } Predicate<String> standardNoSorted = name -> STANDARD_STREAM_INTERMEDIATE_OPERATIONS.contains(name) && !name.equals("sorted"); PsiMethodCallExpression parallelCall = findSubsequentCall(call, "parallel"::equals, standardNoSorted); if (parallelCall != null && findSubsequentCall(call, STANDARD_STREAM_TERMINAL_OPERATIONS::contains, standardNoSorted) != null) { register(parallelCall, JavaBundle.message("inspection.redundant.stream.optional.call.explanation.parallel.single")); } }