Generates a tree