Given a linked list where each node has a child pointer in addition to the next pointer, which may or may not point to a different list. As indicated in the image below, these child lists may have one or more children of their own, and so on, to create a multilayer data structure. The head of the list's initial level is supplied to you. Flatten the list to make a single-level linked list with all of the nodes. You must flatten the list such that all of the first-level nodes appear first, followed by those at the second level, and so forth.