This problem took me a long time. And obviously here the defination of a tree is different from mine... In this problem, just consider it as an undirected graph, and to be a tree, there shouldn't be any loop. So our task is to cut the loop.

Then we can use union find to check if an edge will create a loop simply by checking if the two ends of the edge have the same root: `union.getRoot(edge[0]) == union.getRoot(edge[1])`

. If not, we can assign the root of one end to be the root of the other end:`union.union[union.getRoot(edge[0])] = union.getRoot(edge[1])`

```
class Union(object):
def __init__(self):
self.union = {}
def getRoot(self, node):
if node not in self.union:
self.union[node] = node
while self.union[node] != node:
node = self.union[node]
return node
class Solution(object):
def findRedundantConnection(self, edges):
"""
:type edges: List[List[int]]
:rtype: List[int]
"""
union = Union()
for edge in edges:
if union.getRoot(edge[0]) == union.getRoot(edge[1]):
return edge
else:
union.union[union.getRoot(edge[0])] = union.getRoot(edge[1])
```