[Java] Easy 100% solution
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 So
```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    public Node flatten(Node head) {\n        Node curr = head;\n\n        while(curr != null) {\n            if(curr.child != null) {\n                Node tail = helper(curr.child);\n\n                if(curr.next != null)\n                    curr.next.prev = tail;\n\n                tail.next = curr.next;\n                curr.next = curr.child;\n                curr.child.prev = curr;\n                curr.child = null;\n            }\n            \n            curr = curr.next;\n        }\n\n        return head;\n    }\n\n    private Node helper(Node head) {\n        while(head.next != null)\n            head = head.next;\n\n        return head;\n    }\n}\n```
['Java']