Tree-Based Search for stochastic simulation algorithm