input: Write a Python function that takes an integer list nums, an integer k, and a list of edges representing an undirected tree, and returns the maximum sum Alice can achieve by performing operations on the tree nodes. Alice can choose any edge to XOR the values of the nodes it connects with k any number of times.
output: def max_sum_alice(nums, k, edges):
      from collections import defaultdict
  
      def dfs(node, parent):
          sums = [0]
          xor_values = [nums[node]]
          for neighbor in graph[node]:
              if neighbor != parent:
                  child_sums, child_xors = dfs(neighbor, node)
                  sums.extend(child_sums)
                  xor_values.extend(child_xors)
          best_sum = max(sums + [x ^ k for x in xor_values])
          return sums + [x ^ k for x in xor_values], [x + nums[node] for x in xor_values]
  
      n = len(nums)
      graph = defaultdict(list)
      for u, v in edges:
          graph[u].append(v)
          graph[v].append(u)
  
      return dfs(0, -1)[0][0]