private void processIsNull(@NotNull PsiIfStatement ifStatement,
                                 @NotNull PsiExpression condition,
                                 @NotNull PsiExpression arrayExpression) {
        if (!(ifStatement.getParent() instanceof PsiCodeBlock block)) return;
        PsiStatement thenBranch = ControlFlowUtils.stripBraces(ifStatement.getThenBranch());
        boolean exit;
        PsiStatement expectedAfterStatement = null;
        if (thenBranch instanceof PsiContinueStatement cont &&
            block.getParent() instanceof PsiBlockStatement blockStatement &&
            cont.findContinuedStatement() == blockStatement.getParent()) {
          exit = true;
        }
        else if (thenBranch instanceof PsiReturnStatement ret) {
          exit = true;
          if (ret.getReturnValue() != null || !(block.getParent() instanceof PsiParameterListOwner)) {
            expectedAfterStatement = ret;
          }
        }
        else if (thenBranch instanceof PsiYieldStatement yield) {
          exit = true;
          expectedAfterStatement = yield;
        }
        else {
          exit = false;
        }
        if (!exit) return;
        PsiStatement elseStatement = ControlFlowUtils.stripBraces(ifStatement.getElseBranch());
        PsiStatement nextStatement = PsiTreeUtil.getNextSiblingOfType(ifStatement, PsiStatement.class);
        PsiForeachStatement forEach;
        EquivalenceChecker equivalence = EquivalenceChecker.getCanonicalPsiEquivalence();
        if (equivalence.statementsAreEquivalent(nextStatement, expectedAfterStatement)) {
          forEach = ObjectUtils.tryCast(elseStatement, PsiForeachStatement.class);
        } else {
          if (nextStatement == null) return;
          if (elseStatement != null) return;
          PsiStatement next = PsiTreeUtil.getNextSiblingOfType(nextStatement, PsiStatement.class);
          if (!(equivalence.statementsAreEquivalent(expectedAfterStatement, next) ||
                next == null && expectedAfterStatement instanceof PsiReturnStatement &&
                equivalence.statementsAreEquivalent(expectedAfterStatement, ControlFlowUtils.getNextReturnStatement(nextStatement)))) {
            return;
          }
          forEach = ObjectUtils.tryCast(nextStatement, PsiForeachStatement.class);
        }
        if (forEach != null && equivalence.expressionsAreEquivalent(forEach.getIteratedValue(), arrayExpression)) {
          holder.problem(condition, InspectionGadgetsBundle.message("inspection.redundant.length.check.display.name")).fix(new SimplifyBooleanExpressionFix(condition, false)).register();
        }
      }
private void processIsNull(@NotNull PsiIfStatement ifStatement,
                                 @NotNull PsiExpression condition,
                                 @NotNull PsiExpression arrayExpression)