fixed writing of tree. Branches.