title: Generating a hierarchy from a Python list
body: <p>I am using Python 3.8.</p>
  <p>The following list contains integers and I need to generate a hierarchy from this list:</p>
  <pre><code>list1 = [[15, 1], [22, 1], [23, 1], [121, 15], [101, 22], [105, 23], [106, 23], [108, 23], [155, 121], [120, 108], [19, 2], [25, 5], [33, 8], [35, 8], [28, 25], [29, 28]]
  </code></pre>
  <p>I need this result (output could be a list, e.g. <code>[[[1, 15, 22, 23], [15, 121], [121, 155], [22, 101], [23, 105, 106, 108], [108, 120]], [2, 19], [[5, 25], [25, 28], [28, 29]], [8, 33, 35]]</code>):</p>
  <pre><code>1 ---- 15 ---- 121 ---- 155
   \---- 22 ---- 101
    \--- 23 ---- 105
          \----- 106
           \---- 108 ---- 120
  
  2 ---- 19
  
  5 ---- 25 ---- 28 ----- 29
  
  8 ---- 33
   \---- 35
  </code></pre>
  <p>The hierarchy does not contain any duplicated items. Also first items of the lists in the <code>list1</code> do not contain repeated/duplicated elements, but second items of the lists in the <code>list1</code> contain.</p>
  <p>How could this hierarchy be generated?</p>
  <p><strong>Note</strong>: I could do this by using some code but it could be very long and CPU cost could be high (actual list is very long).</p>