re-assigns parent attribute of the child
beginning to implement DFS