from functools import reduce
from pathlib import PurePosixPath
paths = [
'E:/folder/maps',
'E:/1/2/3',
'E:/folder/new',
'E:/folder/maps/2',
'D:/papka/echepapka',
'E:/1/path/dir',
]
tree = {}
for path in map(PurePosixPath, paths):
reduce(lambda node, part: node.setdefault(part, {}), path.parts, tree)
{'E:': {'folder': {'maps': {'2': {}}, 'new': {}},
'1': {'2': {'3': {}}, 'path': {'dir': {}}}},
'D:': {'papka': {'echepapka': {}}}}
E
|-1
| |-2
| |-3
|-folder
|-maps