Organizes the routes into a prefix tree.
Routes order is preserved such that traversing the tree will traverse the routes in the origin order.
DumperCollection $collection A collection of routes:
private function buildPrefixTree(DumperCollection $collection) {
$tree = new DumperPrefixCollection();
$current = $tree;
foreach ($collection as $route) {
$current = $current
->addPrefixRoute($route);
}
$tree
->mergeSlashNodes();
return $tree;
}