@Nullable("when failed to extract")
  private static List<ComparisonBlock> extractComparisonChain(PsiStatement @NotNull [] statements,
                                                              @NotNull PsiVariable first,
                                                              @NotNull PsiVariable second) {
    if (statements.length == 0) return null;
    ComparisonBlock firstBlock = ComparisonBlock.extractBlock(statements[0], first, second, null);
    if (firstBlock == null) return null;
    List<ComparisonBlock> blocks = new ArrayList<>();
    blocks.add(firstBlock);
    PsiVariable lastResult = firstBlock.getResult();
    int index = 1;
    while (index < statements.length - 1) {
      PsiStatement current = statements[index];
      if (isNotZeroCheck(current, lastResult)) {
        int nextIndex = index + 1;
        if (nextIndex >= statements.length) return null;
        PsiStatement next = statements[nextIndex];
        ComparisonBlock block = ComparisonBlock.extractBlock(next, first, second, lastResult);
        if (block == null) {
          if (nextIndex == statements.length - 1) break;
          return null;
        }
        blocks.add(block);
        index += 2;
        continue;
      }
      PsiStatement nextComparisonStmt = extractZeroCheckedWay(current, lastResult);
      if (nextComparisonStmt != null) {
        ComparisonBlock block = ComparisonBlock.extractBlock(nextComparisonStmt, first, second, lastResult);
        if (block == null) return null;
        blocks.add(block);
        if(block.getResult() != lastResult) lastResult = block.getResult();
        index++;
        continue;
      }
      return null;
    }
    PsiStatement lastStmt = statements[statements.length - 1];
    if (lastStmt instanceof PsiReturnStatement) {
      PsiExpression returnExpr = ((PsiReturnStatement)lastStmt).getReturnValue();
      if (returnExpr == null) return null;
      if (ExpressionUtils.isReferenceTo(returnExpr, lastResult)) {
        return blocks;
      }
      ComparisonBlock lastBlock = extractTernaryComparison(first, second, lastResult, returnExpr);
      if (lastBlock == null) {
        lastBlock = ComparisonBlock.extractBlock(returnExpr, first, second, lastResult);
      }
      if (lastBlock == null) return null;
      blocks.add(lastBlock);
      return blocks;
    }
    return null;
  }
@Nullable("when failed to extract")
  private static List<ComparisonBlock> extractComparisonChain(PsiStatement @NotNull [] statements,
                                                              @NotNull PsiVariable first,
                                                              @NotNull PsiVariable second)