PsiElement (@NotNull PsiElement element) { PsiElement prev = element; PsiElement parent = element.getParent(); while (parent instanceof PsiParenthesizedExpression || parent instanceof PsiTypeCastExpression && ((PsiTypeCastExpression)parent).getOperand() == prev) { prev = parent; parent = parent.getParent(); } return parent; }