Javascript recursive and array
Walk recursively by the order of child and next\n2. Store path sequentially into an array\n3. Untangle the pointers (prev points to previous node next points to
1. Walk recursively by the order of `child` and `next`\n2. Store path sequentially into an array\n3. Untangle the pointers (`prev` points to previous node `next` points to next node)\n```\n/**\n * @param {Node} head\n * @return {Node}\n */\nvar flatten = function(head) {\n    const arr = [];\n    const helper = (node) => {\n        if(!node) return;\n        arr.push(node);\n        helper(node.child);\n        helper(node.next);\n    };\n    helper(head);\n    for(let i = 0; i < arr.length; i++) {\n        arr[i].prev = arr[i-1] || null;\n        arr[i].next = arr[i+1] || null;\n        arr[i].child = null;\n    }\n    return arr[0] || null;\n};\n```
['Recursion', 'JavaScript']