i am study the quick union in coursera and implement it in python.

but a part of code can’t understand.is tree data structure need to learn first?

```
id=[i for i in range(10)]
def root(i):
while i!=id[i]: #this part can not understand,how this declare the root and the loop works
print(i)
i=id[i]
return i
def union(p,q):
i=root(p)
j=root(q)
id[i]=j
def check(p,q):
return root(p)==root(q)
union(2,3)
print(root(2))
```

i hope someone help me to understand this topic.thank you in advance.