fixed tree writing class