title: Create tree like structure
body: <p>In the database, I have data in this format:</p>
  
  <p><img src="https://i.stack.imgur.com/OCKzB.png" alt="enter image description here"></p>
  
  <p>The requirement is to represent the data in the excel in this format: The country name forms the tab name.</p>
  
  <p><img src="https://i.stack.imgur.com/jpg4H.png" alt="enter image description here"></p>
  
  <p>I was thinking to put every DB row in a object.. To achieve in the format, I need to  iterate over the country list, then in each country list (e.g US), pick the list of States (NY, NY) and then within that loop iterate over the each state (e.g NY), so that you get New York and Alaby. Repeat this for other states &amp; then come out of the loop &amp; then iterate over other countries in the same fashion.</p>
  
  <p>But the difficulty I am facing here is, how do I represent that data in Java which will allow me to iterate in the required format? So that when I Iterate over US, it gives me NY  and NJ and when I iterate over NJ, it gives me cities within it. I am struck. Please advice some pointers to get me going</p>