The linked list [x,y,z] is not a valid doubly linked list error??
\n\n    public Node flatten(Node head) {\n        Node curr = head;\n        while(curr!=null){\n            if(curr.child!=null){\n                Node next = 
```\n\n    public Node flatten(Node head) {\n        Node curr = head;\n        while(curr!=null){\n            if(curr.child!=null){\n                Node next = flatten(curr.child);\n                curr.child = null;\n                Node dummyNext = next;\n                next.prev = curr;\n                while(next.next!=null){\n                    next = next.next;\n                }\n                next.next = curr.next;\n                if(curr.next!=null)curr.next.prev = next.next;\n                curr.next = dummyNext;\n                curr = next.next;\n            }else{\n                curr = curr.next;\n            }\n            \n        }\n        return head;\n    }\n\t```\n\t\n\tI made sure all children are null. The output is the following:\n\t\n\t```\n\tOutput: The linked list [1,2,3,7,8,11,12,9,10,4,5,6] is not a valid doubly linked list.\n\tExpected: [1,2,3,7,8,11,12,9,10,4,5,6]\n\t```\n\t
[]