function to generate sets of trees