def retrieve_and_update(self, control, attention=1.0):
    value = None
    ###
    # Retrieve the value - left and right weighted by the value of search
    if self.left and self.right:
      move_right = self.tree.search(self.h, control)
      value = self.right.retrieve_and_update(control, attention=attention * move_right)
      value += self.left.retrieve_and_update(control, attention=attention * (1 - move_right))
    else:
      value = attention * self.value
    ###
    # Update the values of the tree
    if self.left and self.right:
      self.h = self.tree.join(self.left.h, self.right.h)
    else:
      self.h = attention * self.tree.write(self.h, control) + (1 - attention) * self.h
    return value
dataset/ETHPy150Open Smerity/tf-ham/ham.py/HAMNode.retrieve_and_update/original