// array => array
function pack(nodes) {
    return nodes.map(packNode);
}

// array => array
function unpack(packet) {
    return packet.map(unpackNode);
}

// object => (array | string)
function packNode(node) {
    if (node.type === '#') {
        return node.text;
    }
    let item = [node.type];
    let hasProps = (Object.keys(node.props).length !== 0);
    if (hasProps) {
        item.push(node.props);
    }
    if (node.children.length === 0) {
        return item;
    }
    if (!hasProps) {
        item.push(0);
    }
    for (let i = 0; i < node.children.length; i++) {
        item.push(packNode(node.children[i]));
    }
    return item;
}

// (array | string) => array
function unpackNode(item) {
    if (!Array.isArray(item)) {
        return { type: '#', text: item };
    }
    let node = {
        type: item[0],
        props: item[1] || {},
        children: []
    };
    for (let i = 2; i < item.length; i++) {
        node.children.push(unpackNode(item[i]));
    }
    return node;
}

module.exports = {
    pack,
    unpack
};

@@ -534,54 +534,38 @@
     
-for (let i = 0; i %3C node.children.length; i++)
+node.children.forEach(child =%3E
  %7B%0A 
@@ -594,24 +594,13 @@
 ode(
-node.children%5Bi%5D
+child
 ));%0A
@@ -596,32 +596,34 @@
 e(child));%0A    %7D
+);
 %0A    return item

Apply minor changes in Packer