@Override
    public void visitIfStatement(@NotNull PsiIfStatement statement) {
      super.visitIfStatement(statement);
      final PsiElement parent = statement.getParent();
      if (parent instanceof PsiIfStatement) {
        return;
      }
      final PsiExpression condition = statement.getCondition();
      final LanguageLevel languageLevel = PsiUtil.getLanguageLevel(statement);
      final PsiExpression switchExpression = SwitchUtils.getSwitchSelectorExpression(condition);
      if (switchExpression == null) {
        return;
      }
      boolean isPatternMatch = SwitchUtils.canBePatternSwitchCase(condition, switchExpression);
      int branchCount = 0;
      final Set<Object> switchCaseValues = new HashSet<>();
      PsiIfStatement branch = statement;
      int additionalIfStatementCount = 0;

      //otherwise, there may be problems in batch modes
      PsiElement previousElement = PsiTreeUtil.skipWhitespacesAndCommentsBackward(branch);
      if (previousElement instanceof PsiIfStatement previousPsiIfStatement &&
          SwitchUtils.canBeSwitchCase(previousPsiIfStatement.getCondition(), switchExpression, languageLevel, switchCaseValues, isPatternMatch)) {
        return;
      }

      boolean currentIsNextIf = false;
      while (true) {
        branchCount++;
        if (!currentIsNextIf && !SwitchUtils.canBeSwitchCase(branch.getCondition(), switchExpression, languageLevel, switchCaseValues, isPatternMatch)) {
          return;
        }
        currentIsNextIf = false;
        final PsiStatement elseBranch = branch.getElseBranch();
        if (!(elseBranch instanceof PsiIfStatement)) {
          if (elseBranch == null) {
            PsiIfStatement upperIf = branch;
            while (upperIf.getParent() instanceof PsiIfStatement parentIfStatement &&
                   parentIfStatement.getElseBranch() == upperIf) {
              upperIf = parentIfStatement;
            }
            PsiElement nextElement = PsiTreeUtil.skipWhitespacesAndCommentsForward(upperIf);
            if (nextElement instanceof PsiIfStatement nextIfStatement &&
                !ControlFlowUtils.statementMayCompleteNormally(branch.getThenBranch())) {
              if (SwitchUtils.canBeSwitchCase(nextIfStatement.getCondition(), switchExpression, languageLevel, switchCaseValues, isPatternMatch)) {
                branch = nextIfStatement;
                currentIsNextIf = true;
                additionalIfStatementCount++;
                continue;
              }
            }
          }
          break;
        }
        branch = (PsiIfStatement)elseBranch;
      }

      final ProblemHighlightType highlightType;
      if (shouldHighlight(statement, switchExpression, switchCaseValues) && branchCount >= minimumBranches) {
        highlightType = ProblemHighlightType.GENERIC_ERROR_OR_WARNING;
      }
      else {
        if (!isOnTheFly()) return;
        highlightType = ProblemHighlightType.INFORMATION;
      }
      registerError(statement.getFirstChild(), highlightType, additionalIfStatementCount);
    }
@Override
    public void visitIfStatement(@NotNull PsiIfStatement statement)