def METHOD_NAME(root):
    # I don't delete <cropfactor> here in order to be able to replace it with
    # <min-crop-factor> later.
    for element in root.xpath("lens"):
        try:
            calibration = element.xpath("calibration")[0]
        except IndexError:
            continue
        calibration.set("crop-factor", element.xpath("cropfactor")[0].text)
        try:
            aspect_ratio = element.xpath("aspect-ratio")[0]
        except IndexError:
            pass
        else:
            calibration.set("aspect-ratio", aspect_ratio.text)
            aspect_ratio.getparent().remove(aspect_ratio)