[Python] DFS Recursive
\nclass Solution:\n    \n    def maximalPathQuality(self, values: List[int], edges: List[List[int]], maxTime: int) -> int:\n        d = defaultdict(list)\n     
```\nclass Solution:\n    \n    def maximalPathQuality(self, values: List[int], edges: List[List[int]], maxTime: int) -> int:\n        d = defaultdict(list)\n        n = len(values)\n        \n        for edge in edges:\n            d[edge[0]].append([edge[1], edge[2]])\n            d[edge[1]].append([edge[0], edge[2]])\n        \n        visited = [0]*n\n        ans = 0\n        \n        def dfs(node, curTime, total):\n            nonlocal ans\n            if curTime > maxTime:\n                return\n            \n            if visited[node] == 0:\n                total+= values[node]\n            \n            if node == 0:\n                if total > ans:\n                    ans = total\n            \n            visited[node] += 1\n            \n            for vertex, time in d[node]:\n                dfs(vertex, curTime + time, total)\n            \n            visited[node] -= 1\n            \n        dfs(0, 0, 0)\n        return ans\n```
['Depth-First Search', 'Recursion', 'Python3']