The simplest way to traverse the hierarchy tree with [Baum](https://github.com/etrepat/Baum) is by iterating through the `children` relation.
```PHP
with('children')->first();
echo "
{$root->name}
";
foreach($root->children as $category) {
echo "";
echo "{$category->name}";
if ( $category->children()->count() > 0 ) {
echo "";
foreach($category->children as $subCategory)
echo "- {$subCategory}
";
echo "
";
}
echo "";
}
```
This approach is ok if you don't need to go too deep under your hierarchy tree (usually 1 to 3 levels). If you'd need to traverse your tree deeper or, maybe get the full hierarchy tree, you could consider a simple recursive approach.
```PHP
get();
echo "";
foreach($roots as $root) renderNode($root);
echo "
";
// *Very simple* recursive rendering function
function renderNode($node) {
echo "";
echo "{$node->name}";
if ( $node->children()->count() > 0 ) {
echo "";
foreach($node->children as $child) renderNode($child);
echo "
";
}
echo "";
}
```