Extract traverse and write functionality from renderer.
Make writer configurable