KtElement (@NotNull KtLambdaExpression lambda) { PsiElement parent = lambda.getParent(); if (parent instanceof KtValueArgument) { KtCallExpression callExpression = PsiTreeUtil.getParentOfType(parent, KtCallExpression.class, true); if (callExpression != null) { PsiElement parentParent = callExpression.getParent(); if (parentParent instanceof KtQualifiedExpression) { return (KtElement) parentParent; } } return callExpression; } if (parent instanceof KtCallExpression) { return (KtElement) parent; } if (parent instanceof KtProperty && ((KtProperty) parent).isLocal()) { return (KtElement) parent; } return lambda; }