static boolean isLambdaChainParameterReference(PsiExpression expression, Predicate<? super PsiType> chainTypePredicate) {
    if(!(expression instanceof PsiReferenceExpression)) return false;
    PsiParameter target = tryCast(((PsiReferenceExpression)expression).resolve(), PsiParameter.class);
    if (target == null) return false;
    if (!(target.getParent() instanceof PsiParameterList)) return false;
    PsiLambdaExpression lambda = tryCast(target.getParent().getParent(), PsiLambdaExpression.class);
    if (lambda == null) return false;
    PsiExpressionList list = tryCast(PsiUtil.skipParenthesizedExprUp(lambda.getParent()), PsiExpressionList.class);
    if (list == null) return false;
    PsiMethodCallExpression call = tryCast(list.getParent(), PsiMethodCallExpression.class);
    if (call == null) return false;
    PsiMethodCallExpression qualifierCall = call;
    do {
      qualifierCall = MethodCallUtils.getQualifierMethodCall(qualifierCall);
      if (qualifierCall == null) return false;
    }
    while (qualifierCall.getArgumentList().isEmpty());
    PsiType type = qualifierCall.getType();
    return type != null && chainTypePredicate.test(type);
  }
static boolean isLambdaChainParameterReference(PsiExpression expression, Predicate<? super PsiType> chainTypePredicate)