The second parameter is private and should be left blank
X::dump($opt->treeIds(12));
// array [12, 21, 22, 25, 27, 31, 32, 35, 37, 40, 41, 42, 44, 45, 43, 46, 47]
function($id, &$res = [])
{
if ($this->check() && $this->exists($id)) {
$res[] = $id;
if ($its = $this->items($id)) {
foreach ($its as $it){
$this->treeIds($it, $res);
}
}
return $res;
}
return null;
}