Making trees for the layout