public static @NotNull PsiElement getPatternVariableDeclarationScope(@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);
  }
public static @NotNull PsiElement getPatternVariableDeclarationScope(@NotNull PsiPatternVariable variable)