when goal is reached we update the relevent part of the tree.