Context (@NotNull Project project, @NotNull PsiMethodCallExpression call) { PsiLambdaExpression lambda = getLambda(call.getArgumentList().getExpressions()[0]); if (lambda == null) return null; PsiParameter[] parameters = lambda.getParameterList().getParameters(); if (parameters.length != 1) return null; PsiParameter mapLambdaParameter = parameters[0]; PsiExpression argument = LambdaUtil.extractSingleExpressionFromBody(lambda.getBody()); PsiMethodCallExpression insideLambdaCall = tryCast(argument, PsiMethodCallExpression.class); if (insideLambdaCall == null) return null; PsiExpression optionalQualifier = insideLambdaCall.getMethodExpression().getQualifierExpression(); if (optionalQualifier == null) return null; if (!OPTIONAL_OR_ELSE.test(insideLambdaCall)) { if (!OPTIONAL_GET.test(insideLambdaCall)) return null; PsiExpression qualifier = insideLambdaCall.getMethodExpression().getQualifierExpression(); if (!isPresentOptional(qualifier)) return null; return new Context(optionalQualifier, call, mapLambdaParameter); } if (!ExpressionUtils.isNullLiteral(insideLambdaCall.getArgumentList().getExpressions()[0])) return null; return new Context(optionalQualifier, call, mapLambdaParameter); }