serialize tree to html