flatten the hierarchy once all trees are added