PsiElement (@NotNull PsiPatternVariable variable) { PsiElement parent = variable.getPattern().getParent(); if (!(parent instanceof PsiInstanceOfExpression) && !(parent instanceof PsiCaseLabelElementList) && !(parent instanceof PsiPattern) && !(parent instanceof PsiDeconstructionList)) { return parent; } return getInstanceOfPartDeclarationScope(parent); }