simple java and python solution
Java solution\n\nclass Solution {\n    public Node flatten(Node head) \n    {\n        Node curr=head;\n        while(curr!=null)\n        {\n            if(cur
**Java solution**\n```\nclass Solution {\n    public Node flatten(Node head) \n    {\n        Node curr=head;\n        while(curr!=null)\n        {\n            if(curr.child==null)//if the current node doesnt have a child then lets just move to the next node\n            {\n                curr=curr.next;\n                continue;\n            }\n            //if incase a node has child\n            Node temp=curr.child;\n            while(temp.next!=null)\n            {\n                temp=temp.next;//transverse till the tail of that child node\n            }\n            \n            temp.next=curr.next;//again coming back to parent node and transversing thro next nodes\n            if(curr.next!=null)\n            {\n                curr.next.prev=temp;\n            }\n            //merging all nodes\n                curr.next=curr.child;\n                curr.child.prev=curr;\n                curr.child=null;\n        }\n        \n        return head;\n    }\n}\n```\n\n**Python solution**\n```\nclass Solution(object):\n    def flatten(self, head):\n        """\n        :type head: Node\n        :rtype: Node\n        """\n        curr=head\n        while curr!=None:\n            if curr.child==None:\n                curr=curr.next\n                continue\n            \n            temp=curr.child\n            while temp.next!=None:\n                temp=temp.next\n                \n            temp.next=curr.next\n            if curr.next!=None:\n                curr.next.prev=temp\n                \n            curr.next=curr.child\n            curr.child.prev=curr\n            curr.child=None\n        \n        return head\n            \n            \n        \n```
['Python', 'Java']