[Python] Directory tree | Content hash
Create directory tree.\nCalculate hash of each directory.\nConstruct a dictionary which maps the hash to the list of nodes that have this hash.\nFor every hash 
Create directory tree.\nCalculate hash of each directory.\nConstruct a dictionary which maps the hash to the list of nodes that have this hash.\nFor every hash pointing to the list with more than 1 element, mark nodes as deleted.\nRecursively construct all valid paths that were not pruned.\n\n\n```python\nclass Node:\n    def __init__(self):\n        self.children = defaultdict(Node)\n        self.hash = \'\'\n        self.deleted = False\n    \n    def add(self, path, i=0):\n        if i != len(path):\n            self.children[path[i]].add(path, i + 1)\n            \n    def calc_hash(self, hashes, name=\'root\'):\n        for child_name, child in sorted(self.children.items()):\n            self.hash += f\'{child.calc_hash(hashes, child_name)}+\'\n        if self.hash:\n            hashes[self.hash].append(self)\n        return f\'{name}({self.hash})\'\n    \n    def to_list(self, lst, path=[]):\n        for name, node in self.children.items():\n            if not node.deleted:\n                lst.append(path + [name])\n                node.to_list(lst, path + [name])\n\nclass Solution:\n    def deleteDuplicateFolder(self, paths: List[List[str]]) -> List[List[str]]:\n        root = Node()\n        for path in paths:\n            root.add(path)\n        hash_to_nodes = defaultdict(list)\n        root.calc_hash(hash_to_nodes)\n        for nodes in hash_to_nodes.values():\n            if len(nodes) > 1:\n                for node in nodes:\n                    node.deleted = True\n        res = []\n        root.to_list(res)\n        return res\n```
['Tree', 'Python']