Chapter3 : tree functions