def subelement(element, xpath, tag, text, **kwargs):
    subelm = element.find(xpath)

    if subelm is None:
        subelm = etree.SubElement(element, tag)
    else:
        subelm.tag = tag

    subelm.text = text
    for attr, value in kwargs.items():
        subelm.set(attr, value)

    return subelm
Searches element matching the *xpath* in *parent* and replaces it's *tag*,
dataset/ETHPy150Open F-Secure/see/see/context/resources/helpers.py/subelement