code: def update_positions(tree, positions):
      
  
      for step, pos in zip(tree.findall('step'), positions):
          for key in sorted(pos):
              value = pos.get(key)
              if key.endswith("-rel"):
                  abs_key = key[:key.index("-rel")]
                  if value is not None:
                      els = tree.findall(".//*[@id='" + value + "']")
                      for el in els :
                          pos[abs_key] = num(el.get(abs_key)) + pos.get(abs_key)
                          step.attrib[abs_key] = str(pos.get(abs_key))
              else:
                  step.attrib[key] = str(pos[key])
  
          if 'hovercraft-path' in step.attrib:
              del step.attrib['hovercraft-path']
docs: Updates the tree with new positions