@Override
    void collapse(@NotNull PsiElement anchor) {
      if (anchor instanceof PsiIfStatement innerIf && innerIf.getElseBranch() == null) {
        PsiStatement thenBranch = innerIf.getParent() instanceof PsiCodeBlock block && block.getStatementCount() == 1 &&
                                  block.getParent() instanceof PsiBlockStatement blockStatement ? blockStatement : innerIf;
        if (thenBranch.getParent() instanceof PsiIfStatement outerIf && outerIf.getThenBranch() == thenBranch &&
            outerIf.getElseBranch() == null) {
          mergeIfs(outerIf, innerIf);
          return;
        }
      }
      PsiIfStatement ifStatement = tryCast(PsiTreeUtil.skipWhitespacesAndCommentsBackward(anchor), PsiIfStatement.class);
      if (ifStatement == null) return;
      PsiStatement result = collapseIf(ifStatement, "&&", "||");
      if (result == null) return;
      myUpstream.collapse(myUpstream.anchor(result));
    }
@Override
    void collapse(@NotNull PsiElement anchor)