Standart array to tree array : I have a array like this;

[vertical array][1]

But i want to set array by using level key like this;   

[tree view array][2]


  [1]: https://i.stack.imgur.com/Lv8Cm.png
  [2]: https://i.stack.imgur.com/G7Z6V.png