added new routing algorithm, based on a tree model