private static boolean afterInstanceofForType(@Nullable PsiElement position) {
    if (position == null) return false;
    return (InstanceofTypeProvider.AFTER_INSTANCEOF.accepts(position)) &&
           position.getParent() instanceof PsiJavaCodeReferenceElement referenceElement &&
           referenceElement.getParent() instanceof PsiTypeElement typeElement &&
           (typeElement.getParent() instanceof PsiInstanceOfExpression ||
            (typeElement.getParent() instanceof PsiPatternVariable variable &&
             (variable.getParent() instanceof PsiInstanceOfExpression ||
              variable.getParent() instanceof PsiTypeTestPattern typeTestPattern &&
              typeTestPattern.getParent() instanceof PsiInstanceOfExpression)));
  }
private static boolean afterInstanceofForType(@Nullable PsiElement position)