<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def add_element_to_doc(doc, tag, value):
 """Set text value of an etree.Element of tag, appending a new element with given tag if it doesn't exist."""

    element = doc.find(".//%s" % tag)
    if element is None:
        element = etree.SubElement(doc, tag)
    element.text = value