function mkdir_p(level) {
      cache.length = level + 1;
      var obj = cache[level];
      if (!obj) {
        var parent = (level > 1) ? mkdir_p(level-1) : root;
        obj = { items: [], level: level };
        cache = cache.concat([obj, obj]);
        parent.items.push(obj);
      }
      return obj;
    }
Returns menu data for a given HTML.

    menu = Flatdoc.transformer.getMenu($content);
    menu == {
      level: 0,
      items: [{
        section: "Getting started",
        level: 1,
        items: [...]}, ...]}