Tell me how best to generate an array, nesting is about 4-5 levels. The structure in the database is as follows. 
The parent field defines the parent in which the element is nested. Parent-0 is the root node. With the first query I will pull out all the root nodes, the second one already all that are not equal to 0. It is interesting how to construct the array itself with such nesting.