optimised the generation and exploration of the tree