def pom_add_or_modify_tag(root, tag, text, insert_index=None):
    """
    Modifies the value of the given child, or adds the child if it doesn't exist
    """
    child = root.find(tag)
    if child is None:
        child = Xml.Element(tag)
        if insert_index is None:
            root.append(child)
        else:
            root.insert(insert_index, child)
    child.text = text
dataset/ETHPy150Open databricks/spark-package-cmd-tool/python/spark_package/spark_package.py/pom_add_or_modify_tag/original