Java short and concise with stack
\npublic Node flatten(Node head) {\n        if(head == null){\n            return head;\n        }\n        \n        Stack<Node> stack = new Stack<>();\n      
```\npublic Node flatten(Node head) {\n        if(head == null){\n            return head;\n        }\n        \n        Stack<Node> stack = new Stack<>();\n        stack.push(head);\n        Node prev = null;\n        \n        while(!stack.empty()){\n            Node node = stack.pop();\n            if(node.next != null){\n                stack.push(node.next);\n            }\n            if(node.child != null){\n                stack.push(node.child);\n                node.child = null;\n            }\n            node.next = stack.empty() ? null : stack.peek();\n            node.prev = prev;\n            prev = node;\n        }\n        \n        return head;\n    }\n```
['Java']