python def visit(v):
for c in children[v]:
parent[c] = v
visit(c)
visit(root)
python stack = [root]
while stack:
v = stack.pop()
for c in children[v]:
parent[c] = v
stack.append(c)