public static @Nullable PsiTypeElement getPatternTypeElement(@Nullable PsiCaseLabelElement pattern) {
    if (pattern == null) return null;
    else if (pattern instanceof PsiDeconstructionPattern) {
      return ((PsiDeconstructionPattern)pattern).getTypeElement();
    }
    else if (pattern instanceof PsiTypeTestPattern) {
      return ((PsiTypeTestPattern)pattern).getCheckType();
    }
    else if (pattern instanceof PsiUnnamedPattern) {
      return ((PsiUnnamedPattern)pattern).getTypeElement();
    }
    return null;
  }
public static @Nullable PsiTypeElement getPatternTypeElement(@Nullable PsiCaseLabelElement pattern)