protected function putInTree(CategoryInterface $category, array &$tree) { if (null === $category->getParent()) { $tree[$category->getId()] = $category; } else { $this->putInTree($category->getParent(), $tree); } }