PsiExpression (PsiExpression expression) { while (true) { PsiElement parent = expression.getParent(); if (parent instanceof PsiParenthesizedExpression || parent instanceof PsiTypeCastExpression || parent instanceof PsiConditionalExpression) { expression = (PsiExpression)parent; continue; } if (parent instanceof PsiReferenceExpression) { PsiMethodCallExpression grandParent = ObjectUtils.tryCast(parent.getParent(), PsiMethodCallExpression.class); if (DERIVED.test(grandParent)) { expression = grandParent; continue; } } if (parent instanceof PsiExpressionList) { PsiMethodCallExpression grandParent = ObjectUtils.tryCast(parent.getParent(), PsiMethodCallExpression.class); if (TRANSFORMED.test(grandParent)) { expression = grandParent; continue; } } break; } return expression; }