boolean (@NotNull PsiExpression expression) { PsiElement element = expression; while (element instanceof PsiExpression) { final PsiElement parent = element.getParent(); if (parent instanceof PsiIfStatement && element == ((PsiIfStatement)parent).getCondition()) return true; element = parent; } return false; }