getId()] = $obj; if (is_null($obj->getPid())) { $data[] = $obj; } } foreach ($objList as $key => $obj) { if (!is_null($obj->getPid()) && isset($objList[$obj->getPid()])) { $objList[$obj->getPid()]->addChildrenToTop($obj); } } return $data; } }