code: function extendAst(node, parent) {
    node = new AstNode(node);
  
    node.parent = parent || null;
    node.prev = null;
    node.next = null;
    if (node.nodes) {
      var children = node.nodes;
      node.nodes = [];
      children.forEach(function (childNode, i) {
        if (childNode.type) {
          node.nodes.push(extendAst(childNode, node));
        } else {
          node.nodes.push(childNode);
        }
      });
  
      node.nodes.forEach(function (childNode, i) {
        if (childNode.type) {
          if (i > 0) {
            childNode.prev = node.nodes[i - 1];
          }
          if (i < node.nodes.length) {
            childNode.next = node.nodes[i + 1];
          }
        }
      });
    }
  
    return node;
  }
docs: /*
  Takes a plain object representing a node, converts it to an AstNode and attaches
  it to a parent in an AstNode tree.
  @param {Object} node Plain object representing a node.
  @param {String} node.type Type of the node.
  @param {Array} [node.nodes] Child nodes that will also be converted.
  @param {AstNode} parent Parent AstNode in the tree.