public static function makeTree($Categories, $Root = null)
{
$Result = array();
$Categories = (array) $Categories;
if ($Root) {
$Result = self::instance()->collection->getTree((int) val('CategoryID', $Root), ['depth' => self::instance()->getMaxDisplayDepth() ?: 10]);
self::instance()->joinRecent($Result);
} else {
// Make a tree out of all categories.
foreach ($Categories as $Category) {
if (isset($Category['Depth']) && $Category['Depth'] == 1) {
$Row = $Category;
$Row['Children'] = self::_MakeTreeChildren($Row, $Categories, 0);
$Result[] = $Row;
}
}
}
return $Result;
}