protected function getTree(){ $tree = []; debug($this->data);//тестовая ф-ция выводит массив категорий как положено foreach ($this->data as $id=>&$node) if (!$node['parent_id']){//здесь возникает ошибка $tree[$id] = &$node; } else { $this->data[$node['parent_id']]['childs'][$node['id']] = &$node; } } return $tree; } The code stopped working suddenly. Thank you in advance.