title: magento - retrieve all children categories given a category id
body: <p>As said in the title, i'm trying to do this stuff through my custom function:</p>
  
  <pre><code>public function retrieveAllChilds($id = null, $childs = null){
  
          $childIdsArray = is_null($childs) ? array() : $childs;
          $category = is_null($id) ? $this-&gt;getCurrentCategory() : $this-&gt;getCategoryFromId($id);
          if (count($this-&gt;getChildrenCategories($id)) &gt; 0) {
              $c = count($this-&gt;getChildrenCategories($id));
              $tmp_array = array();
              foreach ($this-&gt;getChildrenCategories($id) as $category) {
                  array_push($tmp_array, $category-&gt;getId());             
              }
              $childIdsArray = array_merge($childIdsArray, $tmp_array);
              foreach ($this-&gt;getChildrenCategories($id) as $category){
                  $this-&gt;retrieveAllChilds($category-&gt;getId(), $childIdsArray);
              }
          }
          else{
              return array_unique($childIdsArray);
          }
  
          return array_unique($childIdsArray);
  }
  </code></pre>
  
  <p>but seems that there's something wrong in the stop or in the exit condition. the function retrieve correctly first 16 elements. anybody could help me?</p>