Tree writer class complete