private static boolean hasUnconditionalPatternCheck(PsiIfStatement ifStatement, PsiExpression switchExpression){
    final PsiType type = switchExpression.getType();
    if (type == null) return false;

    PsiIfStatement currentIfInChain = ifStatement;
    while (currentIfInChain != null) {
      final PsiExpression condition = PsiUtil.skipParenthesizedExprDown(currentIfInChain.getCondition());
      if (condition instanceof PsiPolyadicExpression polyadicExpression) {
        if (JavaTokenType.OROR.equals(polyadicExpression.getOperationTokenType())) {
          if (ContainerUtil.exists(polyadicExpression.getOperands(), (operand) -> hasUnconditionalPatternCheck(type, operand))) {
            return true;
          }
        }
      }
      if (hasUnconditionalPatternCheck(type, condition)) {
        return true;
      }
      final PsiStatement elseBranch = currentIfInChain.getElseBranch();
      if (elseBranch instanceof PsiIfStatement) {
        currentIfInChain = (PsiIfStatement)elseBranch;
      } else {
        currentIfInChain = null;
      }
    }

    return false;
  }
private static boolean hasUnconditionalPatternCheck(PsiIfStatement ifStatement, PsiExpression switchExpression)