Adaptive tree-based search for stochastic simulation algorithm