javascript DFS extremely simple and understandable
DFS, pass down rightnode\'s left pointer if it exists, otherwise null.\n\nvar connect = function(root, rightNode = null) {\n    if (!root) return root;\n    \n 
DFS, pass down rightnode\'s left pointer if it exists, otherwise null.\n```\nvar connect = function(root, rightNode = null) {\n    if (!root) return root;\n    \n    root.next = rightNode;\n    connect(root.left, root.right);\n    connect(root.right, rightNode ? rightNode.left : null);\n    \n    return root;\n};\n```
['Depth-First Search', 'JavaScript']