modified tree writer