Add a function for updating the parent and grammar of nodes.