Added code for some tree algorithms