@Override
    void collapse(@NotNull PsiElement anchor) {
      PsiBlockStatement blockStatement = tryCast(anchor, PsiBlockStatement.class);
      if (blockStatement == null) return;
      PsiStatement statement = ControlFlowUtils.getOnlyStatementInBlock(blockStatement.getCodeBlock());
      if (statement == null) return;
      if (statement instanceof PsiIfStatement &&
          blockStatement.getParent() instanceof PsiIfStatement &&
          ((PsiIfStatement)blockStatement.getParent()).getThenBranch() == blockStatement) {
        // if(...) {if(...)} else {...} -- do not unwrap nested `if`
        return;
      }
      new CommentTracker().replaceAndRestoreComments(blockStatement, statement);
    }
@Override
    void collapse(@NotNull PsiElement anchor)