Simple tree build for routing but may be used in other places.