For this Question: Given a linked list where in addition to the next pointer, each node has a child pointer, which may or may not point to a separate list. These child lists may have one or more children of their own, and so on, to produce a multilevel data structure, as shown in below figure.You are given the head of the first level of the list. Flatten the list so that all the nodes appear in a single-level linked list. You need to flatten the list in way that all nodes at first level should come first, then nodes of second level, and so on.User task:
Since this is a functional problem you don't have to worry about input, you just have to complete the function <b>flattenList()</b>  that takes the head node of the tree as input.

Constraints:
1 <= N <= 100
1 <= Data of Nodes <= 100You don't need to print anything you just need to make the given head as the head of the singly linked list.
Printing is done by the driver codeSample Input:-
1     →      2      →     3     →    4
↓            ↓                       ↓
9 → 8       11 → 12                 5 → 6 → 7
             ↓
            13 → 14 → 15

Sample Output:-
1 2 3 4 9 8 11 12 5 6 7 13 14 15, I have written this Solution Code:  static  void flattenList(Node head)  
    {  
     /*Base case*/
     if (head == null) { 
         return; 
     } 
       
     Node tmp = null; 
     /* Find tail node of first level linked list */
     Node tail = head; 
     while (tail.next != null) { 
         tail = tail.next; 
     } 

     // One by one traverse through all nodes of first level 
     // linked list till we reach the tail node 
     Node cur = head; 
     while (cur != tail) { 

         // If current node has a child 
         if (cur.Child != null) { 

             // then append the child at the end of current list 
             tail.next = cur.Child; 

             // and update the tail to new last node 
             tmp = cur.Child; 
             while (tmp.next != null) { 
                 tmp = tmp.next; 
             } 
             tail = tmp; 
         } 

         // Change current node 
         cur = cur.next; 
     }
    }, In this Programming Language: Java, Now tell me if this Code is compilable or not?