How-to get hierarchical categories that contains a least one product
<p>Assuming the following hierarichal parent/child category model :</p>

<pre><code>    public class Category
    {
        public int CategoryId { get; set; }
        public Category ParentCategory { get; set; }
        public IList&lt;Category&gt; ChildCategories { get; set; }
        public IList&lt;Product&gt; Products { get; set; }
    }
</code></pre>

<p>I want to get all categories in a hierarchical way that contains at least one product.</p>

<p>Root Category</p>

<p>a1. Sub Category 1 (0 product)</p>

<p>a2. Sub Category 2 (1 product)</p>

<p>b1. Sub Category 1 (0 product)</p>

<p>b2. Sub Category 2 (1 product)</p>

<p>b3. Sub Category 3 (0 product)</p>

<p>The expected result is :</p>

<p>Root Category</p>

<p>a1. Sub Category 1</p>

<p>a2. Sub Category 2</p>

<p>b1. Sub Category 1</p>

<p>b2. Sub Category 2</p>

<p>Thanks.</p>
