title: Algorithm for converting Category Tree to Flat List
body: <p>I am trying to convert a Categories Tree to a flat list.</p>
  
  <p>In the Categories any category can have n levels of subcategories.</p>
  
  <pre><code>For Ex.:
  
  Category1
  -SubCategory1
  -SubCategory2
  --SubCategor1
  ---SubCategory1
  ---SubCategory2
  ----SubCategory1
  ----SubCategory2
  ---SubCategory3
  --SubCategory2
  -SubCategory3
  
  Category2
  -SubCategory1
  --SubCategory1
  ---SubCategory1
  ----SubCategory1
  ---SubCategory3
  -SubCategory3
  
  ...etc and so on.
  </code></pre>
  
  <p>Language is not a barrier I am just trying to formulate loops/nested loops to create this logic to convert it into a flattened list.</p>
  
  <p>Any help will be highly appreciated.</p>
  
  <p>Thanks in Advance</p>