How to convert 2D list(list in list) to tree-data structure?

There is some relevant discussion here: