<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def update_positions(tree, positions):
 """Updates the tree with new 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']