def findTypeParent(element, tag):

    p = element
    while True:
        p = p.getparent()
        if p.tag == tag:
            return p

    # Not found
    return None
Finds fist parent of element of the given type
dataset/ETHPy150Open clips/pattern/pattern/web/docx/docx.py/findTypeParent