Template:Tree search algorithm