Need to turn x:
X = [['A', 'B', 'C'], ['A', 'B', 'D']]
Into Y:
Y = {'A': {'B': {'C','D'}}}
More specifically, I need to create a tree of folders and files from a list of absolute paths, which looks like this:
paths = ['xyz/123/file.txt', 'abc/456/otherfile.txt']
where, each path is split("/"), as per ['A', 'B', 'C'] in the pseudo example.
As this represents files and folders, obviously, on the same level (index of the array) same name strings can’t repeat.
This leaves us with d containing
{'A': {'B': {'C': {}, 'D': {}}}, 'W': {'Y': {'Z': {}}, 'X': {}}}. Any item containing an empty dictionary is either a file or an empty directory.