@Override
  public @NotNull PsiElementVisitor buildVisitor(@NotNull ProblemsHolder holder, boolean isOnTheFly) {

    return new JavaElementVisitor() {
      @Override
      public void visitMethodCallExpression(@NotNull PsiMethodCallExpression call) {
        super.visitMethodCallExpression(call);
        PsiElement nameElement = call.getMethodExpression().getReferenceNameElement();
        if (nameElement == null || !isCollectorMethod(call, "groupingBy", "groupingByConcurrent")) return;
        PsiExpression[] args = call.getArgumentList().getExpressions();
        if (args.length != 2 && args.length != 3) return;
        CombinedCollector combinedCollector = new CombinedCollector(ArrayUtil.getLastElement(args), null, null);
        // Unwrap at most twice to gather collectingAndThen and/or mapping
        combinedCollector = combinedCollector.tryUnwrap().tryUnwrap();
        PsiMethodCallExpression downstream = ObjectUtils.tryCast(combinedCollector.myDownstream, PsiMethodCallExpression.class);
        if (downstream == null ||
            !FunctionalExpressionUtils
              .isFunctionalReferenceTo(combinedCollector.myFinisher, CommonClassNames.JAVA_UTIL_OPTIONAL, null, "get")) {
          return;
        }
        if (isCollectorMethod(downstream, "maxBy", "minBy", "reducing") &&
            downstream.getArgumentList().getExpressionCount() == 1) {
          String replacement = nameElement.getText().equals("groupingBy") ? "toMap" : "toConcurrentMap";
          holder.registerProblem(nameElement, JavaBundle.message("inspection.simplify.collector.message", replacement),
                                 new SimplifyCollectorFix(replacement));
        }
      }
    };
  }
@Override
  public @NotNull PsiElementVisitor buildVisitor(@NotNull ProblemsHolder holder, boolean isOnTheFly)