✅EASY JAVA SOLUTION
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n![Up.png](https://assets.leetcode.com/users/images/00e26714-a384-4a24-a89d-307556b55ab1_1724210488.1481497.png)\n\n```java []\n/*\n// Definition for a Node.\nclass Node {\n    public int val;\n    public Node prev;\n    public Node next;\n    public Node child;\n};\n*/\n\nclass Solution {\n   private Queue<Node> store = new LinkedList<>();\n\npublic void helper(Node head)\n{\n    Node temp;\n    while (head != null)\n    {\n        temp = head.next;\n        head.next = null;\n        head.prev = null;\n        store.offer(head);\n        if (head.child != null)\n            helper(head.child);\n        head.child = null;\n        head = temp;\n    }\n}\n\npublic Node flatten(Node head) {\n    helper(head);\n    if (store.peek() == null)\n        return head;\n    Node retval = store.poll();\n    Node first = retval;\n    while (store.peek() != null)\n    {\n        Node second = store.poll();\n        first.next = second;\n        second.prev = first;\n        first = second;\n    }\n    first.next = null;\n    return retval;\n}\n}\n```
['Queue', 'Java']