title: building a tree from a csv file using python
body: <p>My csv file has the following format</p>
  
  <pre><code>Col1        Col2
  a           b
  b           c
  c           d
  d           e
  x           b
  y           c
  z           c
  m           x
  h           b
  i           b
  </code></pre>
  
  <p>I will create a dictionary to hold this data like this</p>
  
  <pre><code>{ b:[a,x,h,i] , c:[b,y,z], d:[c], e:[d], x:[m] } 
  </code></pre>
  
  <p>From this dictionary I want to be able to build a hierarchy. For example: when I walk through the dictionary for 'a' I should be able to display</p>
  
  <pre><code> a -&gt; b -&gt; c -&gt; d -&gt; e
  </code></pre>
  
  <p>Similarly for 'y'</p>
  
  <pre><code> y -&gt; c -&gt; d -&gt; e
  </code></pre>
  
  <p>I can think of this as a tree structure and imagine this to be a depth first traversal, but I am unsure about how to achieve this with a dictionary in python. This would not be a decision tree or a binary tree etc. </p>