boolean (@NotNull LocalSearchScope scope, PsiElement expression) { while (true) { final PsiElement parent = expression.getParent(); if (parent != null && scope.containsRange(parent.getContainingFile(), parent.getTextRange())) { if (parent instanceof PsiIfStatement || parent instanceof PsiConditionalExpression || parent instanceof PsiSwitchStatement) { return false; } } else { return true; } expression = parent; } }