Generate correctly the data for the tree