title: Find if a category exists using just the category name
body: <p>I'm building a custom product import module for Magento and have never worked with Magento before in any regard. </p>
  
  <p>I have a CSV file that contains all of the products. One of the columns contains the Category that the product should be assigned to separated by slashes. Ex: </p>
  
  <pre><code>Jewelry / Rings / Diamond
  Jewelry / Neckless / Diamond
  </code></pre>
  
  <p>ect.</p>
  
  <p>The problem I have is that the Diamond category can exist as a sub category in any number of parent categories. My solution was to break the path up (i.e. expload($categoryPath, "/"))</p>
  
  <p>Using the first example (Jewelry / Rings / Diamond) I start at the stores root category and check to see if it contains a subcategory of Jewelry, if it does i get the ID of that subcategory and recursively make my way to the finish line, or at least that's the theory.</p>
  
  <p>The problem I'm running into is right here...</p>
  
  <pre><code>$rootCategory = Mage::getModel('catalog/category') -&gt; load($rootCategoryId);
  $currentCategory = $rootCategory -&gt; getChildrenCategories() -&gt; loadByAttribute('name', $targetCategoryName);
  </code></pre>
  
  <p>This throws me an error  ..."Call to a member function getName() on a non-object in"... I assume because getChildrenCategories() is returning a collection and i can not call loadByAttribute on it. </p>
  
  <p>If this makes sense to anyone, please let me know how I can load a subcategory from the root category by using only the name. I was hoping that if loadByAttribute fails to load the category (because it does not exist) that it would return False and i can then create the category.
  <hr/>
  In response to Pavels suggestion i tryed :</p>
  
  <pre><code>$targetCategoryName = 'Jewelry';
  
  $subCategories = $rootCategory
                      -&gt; getChildrenCategories()
                      -&gt; addAttributeToFilter('name',$targetCategoryName) 
                      -&gt; setCurPage(1)
                      -&gt; setPageSize(1)
                      -&gt; load();
  
      $currentCategory = $subCategories
                      -&gt; getFirstItem();
  </code></pre>
  
  <p>The name of $currentCategory is 'dummy-category'. It would seem the filter is not working.</p>