Adding parent reference to the nodes