docs: function ast_squeeze(ast, options) {
          options = defaults(options, {
                  make_seqs: true
          });
  
          var w = ast_walker(), walk = w.walk;
  
          function is_constant(node) {
                  return node[0] == "string" || node[0] == "num";
          };
  
          function rmblock(block) {
                  if (block != null && block[0] == "block" && block[1] && block[1].length == 1)
                          block = block[1][0];
                  return block;
          };
  
          function _lambda(name, args, body) {
                  return [ this[0], name, args, tighten(body.map(walk)) ];
          };
  
          // we get here for blocks that have been already transformed.
          // this function does two things:
          // 1. discard useless blocks
          // 2. join consecutive var declarations
          function tighten(statements) {
                  var cur, prev;
                  for (var i = 0, ret1 = []; i < statements.length; ++i) {
                          cur = statements[i];
                          if (cur[0] == "block") {
                                  if (cur[1]) {
                                          ret1.push.apply(ret1, cur[1]);
                                  }
                          } else {
                                  ret1.push(cur);
                          }
                  }
                  prev = null;
                  for (var i = 0, ret2 = []; i < ret1.length; ++i) {
                          cur = ret1[i];
                          if (prev && ((cur[0] == "var" && prev[0] == "var") ||
                                       (cur[0] == "const" && prev[0] == "const"))) {
                                  prev[1] = prev[1].concat(cur[1]);
                          } else {
                                  ret2.push(cur);
                                  prev = cur;
                          }
                  }
                  if (!options.make_seqs)
                          return ret2;
                  prev = null;
                  for (var i = 0, ret3 = []; i < ret2.length; ++i) {
                          cur = ret2[i];
                          if (!prev) {
                                  if (cur[0] == "stat") {
                                          prev = [ "seq", cur[1] ];
                                          ret3.push([ "stat", prev ]);
                                  } else {
                                          ret3.push(cur);
                                  }
                          } else if (cur[0] == "stat") {
                                  prev.push(cur[1]);
                          } else if (cur[0] == "seq") {
                                  prev.push.apply(prev, slice(cur, 1));
                          } else {
                                  prev = null;
                                  ret3.push(cur);
                          }
                  }
                  return ret3.map(walk);
          };
  
          function best_of(ast1, ast2) {
                  return gen_code(ast1).length > gen_code(ast2[0] == "stat" ? ast2[1] : ast2).length ? ast2 : ast1;
          };
  
          function aborts(t) {
                  if (t[0] == "block" && t[1] && t[1].length > 0)
                          t = t[1][t[1].length - 1]; // interested in last statement
                  if (t[0] == "return" || t[0] == "break" || t[0] == "continue" || t[0] == "throw")
                          return true;
          };
  
          function make_conditional(c, t, e) {
                  if (c[0] == "unary-prefix" && c[1] == "!") {
                          return e ? [ "conditional", c[2], e, t ] : [ "binary", "||", c[2], t ];
                  } else {
                          return e ? [ "conditional", c, t, e ] : [ "binary", "&&", c, t ];
                  }
          };
  
          function empty(b) {
                  return !b || (b[0] == "block" && (!b[1] || b[1].length == 0));
          };
  
          return w.with_walkers({
                  "sub": function(expr, subscript) {
                          if (subscript[0] == "string") {
                                  var name = subscript[1];
                                  if (is_identifier(name)) {
                                          return [ "dot", walk(expr), name ];
                                  }
                          }
                  },
                  "if": function(c, t, e) {
                          c = walk(c);
                          t = walk(t);
                          e = walk(e);
                          var negated = c[0] == "unary-prefix" && c[1] == "!";
                          if (empty(t)) {
                                  if (negated) c = c[2];
                                  else c = [ "unary-prefix", "!", c ];
                                  t = e;
                                  e = null;
                          }
                          if (empty(e)) {
                                  e = null;
                          } else {
                                  if (negated) {
                                          c = c[2];
                                          var tmp = t; t = e; e = tmp;
                                  }
                          }
                          if (empty(e) && empty(t))
                                  return [ "stat", c ];
                          var ret = [ "if", c, t, e ];
                          if (t[0] == "stat") {
                                  if (e) {
                                          if (e[0] == "stat") {
                                                  ret = best_of(ret, [ "stat", make_conditional(c, t[1], e[1]) ]);
                                          }
                                  }
                                  else {
                                          ret = best_of(ret, [ "stat", make_conditional(c, t[1]) ]);
                                  }
                          }
                          else if (e && t[0] == e[0] && (t[0] == "return" || t[0] == "throw")) {
                                  ret = best_of(ret, [ t[0], make_conditional(c, t[1], e[1] ) ]);
                          }
                          else if (e && aborts(t)) {
                                  ret = [ [ "if", c, t ] ];
                                  if (e[0] == "block") {
                                          if (e[1]) ret = ret.concat(e[1]);
                                  }
                                  else {
                                          ret.push(e);
                                  }
                                  ret = [ "block", ret ];
                          }
                          return ret;
                  },
                  "toplevel": function(body) {
                          return [ "toplevel", tighten(body.map(walk)) ];
                  },
                  "switch": function(expr, body) {
                          return [ "switch", walk(expr), tighten(body.map(walk)) ];
                  },
                  "function": _lambda,
                  "defun": _lambda,
                  "block": function(body) {
                          if (body) return rmblock([ "block", tighten(body.map(walk)) ]);
                  },
                  "binary": function(op, left, right) {
                          left = walk(left);
                          right = walk(right);
                          var best = [ "binary", op, left, right ];
                          if (is_constant(left) && is_constant(right)) {
                                  var val = null;
                                  switch (op) {
                                      case "+": val = left[1] + right[1]; break;
                                      case "*": val = left[1] * right[1]; break;
                                      case "/": val = left[1] / right[1]; break;
                                      case "-": val = left[1] - right[1]; break;
                                  }
                                  if (val != null) {
                                          best = best_of(best, [ typeof val == "string" ? "string" : "num", val ]);
                                  }
                          }
                          return best;
                  },
                  "conditional": function(c, t, e) {
                          if (c[0] == "unary-prefix" && c[1] == "!")
                                  return [ "conditional", walk(c[2]), walk(e), walk(t) ];
                  },
                  "seq": function() {
                          if (arguments.length == 1)
                                  return walk(arguments[0]);
                  }
          }, function() {
                  return walk(ast);
          });
  
  }