Generates a random tree