code: function nestTokens(tokens) {
      var tree = [];
      var collector = tree;
      var sections = [];
      var token, section;
  
      for (var i = 0; i < tokens.length; ++i) {
        token = tokens[i];
  
        switch (token[0]) {
        case "#":
        case "^":
          token[4] = [];
          sections.push(token);
          collector.push(token);
          collector = token[4];
          break;
        case "/":
          if (sections.length === 0) {
            throw new Error("Unopened section: " + token[1]);
          }
  
          section = sections.pop();
  
          if (section[1] !== token[1]) {
            throw new Error("Unclosed section: " + section[1]);
          }
  
          if (sections.length > 0) {
            collector = sections[sections.length - 1][4];
          } else {
            collector = tree;
          }
          break;
        default:
          collector.push(token);
        }
      }
  
      // Make sure there were no open sections when we're done.
      section = sections.pop();
  
      if (section) {
        throw new Error("Unclosed section: " + section[1]);
      }
  
      return tree;
    }
docs: Forms the given array of `tokens` into a nested tree structure where
  tokens that represent a section have a fifth item: an array that contains
  all tokens in that section.