title: Algorithm to create a tree structure using excel sheet
body: <p>I have faced a problem when creating a tree structure using following excel sheet. </p>
  
  <p><a href="https://i.stack.imgur.com/TCc0r.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/TCc0r.png" alt="enter image description here"></a></p>
  
  <p>I wanted to store those cell elements as categories. There are many to many relationship between each categories. That means each parent category has many child categories and also each child category has many parent categories. </p>
  
  <p><a href="https://i.stack.imgur.com/qnPNb.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qnPNb.png" alt="enter image description here"></a></p>
  
  <p>I'm going to use PHP as language but it is not important. </p>
  
  <p>If there anyone who had this kind of experience or any idea to traverse and store categories as a tree(parent child relationship), it will be very helpful for me.</p>
  
  <p>//==============Update===================</p>
  
  <p>Number of columns may be different. That means there are number of excel files and their headings' count and heading name may be different. Therefore I need to find common solution for all sheets. </p>
  
  <p>Thanks.</p>