PsiElement (PsiExpression expression) { PsiElement parent = ParenthesesUtils.getParentSkipParentheses(expression); if (parent == null) { return null; } PsiElement grandParent = parent.getParent(); final PsiType type = expression.getType(); if (type == null) { return null; } while (parent instanceof PsiReferenceExpression && grandParent instanceof PsiMethodCallExpression methodCallExpression) { if (!type.equals(methodCallExpression.getType())) { return null; } parent = ParenthesesUtils.getParentSkipParentheses(grandParent); if (parent == null) { return null; } grandParent = parent.getParent(); } return parent; }