Adding tree code