I have a list of directories like this
a
a/b
a/c
a/d
a/d/e
a/d/f
a/d/g
a/d/g/h
a/i
I would like to convert this list into another list, nested like this
a{b{} c{} d{e{} f{} g{h{}}} i{}}
Here is a pseudo algorithm for this
Add a:
a{}
Add b:
a{ b{}}
Add c:
a{b{} c{}}
Add d:
a{b{} c{} d{}}
Add e:
a{b{} c{} d{ e{}}}
Add f:
a{b{} c{} d{e{} f{}}}
Add g:
a{b{} c{} d{e{} f{} g{}}}
Add h:
a{b{} c{} d{e{} f{} g{ h{}}}}
Add i:
a{b{} c{} d{e{} f{} g{h{}}} i{}}
How can I achieve this?
Thank you!