Simple python3 solution | DFS + Greedy
Complexity\n- Time complexity: O(n)\n Add your time complexity here, e.g. O(n) \n\n- Space complexity: O(n)\n Add your space complexity here, e.g. O(n) \n\n# Co
# Complexity\n- Time complexity: $$O(n)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: $$O(n)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n``` python3 []\nclass Solution:\n    def maximumValueSum(self, nums: List[int], k: int, edges: List[List[int]]) -> int:\n        vs = defaultdict(list)\n        for u, v in edges:\n            vs[u].append(v)\n            vs[v].append(u)\n        \n        def dfs(u, prev):\n            not_swap, swap = 0, -float(\'inf\')\n            for v in vs[u]:\n                if v == prev:\n                    continue\n                child_not_swap, child_swap = dfs(v, u)\n                not_swap, swap = (\n                    max(not_swap + child_not_swap, swap + child_swap),\n                    max(swap + child_not_swap, not_swap + child_swap),\n                )\n            \n            value = nums[u]\n            value_xor = nums[u] ^ k\n            return (\n                max(not_swap + value, swap + value_xor),\n                max(swap + value, not_swap + value_xor),\n            )\n        \n        return dfs(0, -1)[0]\n```
['Greedy', 'Depth-First Search', 'Recursion', 'Binary Tree', 'Python3']