def get_parent_by_tag(element, tag):
    """
    Get parent of element by tag name.
    :param element: child element
    :param tag: tag of parent element
    :return: parent element
    """
    parent = element.getparent()
    if tag == parent.tag:
        return parent
    else:
        return get_parent_by_tag(parent, tag)