I think I start seeing what you want. A few questions: 1) Can the leafs be of the same type as the root and child? 2) Does every child need to have one child at least? (= no child with zero leafs)
you can do the following: ```julia # this generates a list of empty vectors that can hold MyNode types, each of these vectors # will then be filled with leafs # once all vectors are filled with leafs we can distribute them to the children all_leafs = Any[MyNode[] for i in 1:nChildren] for i in 1:100 childIndex = rand(1:nChildren) # pick to which child this leaf will go #create your leaf here with necessary stuff like above leaf=MyNode(data,level, MyNode[], 0) push!(all_leafs[childIndex], leaf) end ``` then you can distribute those leafs: ```julia for i in 1:nChildren root.child[i].child = all_leafs[i] end ```