Adding the code for trees