:return: an element losslessly as a dictionary. If recurse is True,
    the element's children are included, otherwise they are omitted.

    The resulting Dictionary will have the following attributes:
        - name: the name of the element tag
        - text: the text contained by element
        - tail: text immediately following the element
        - attributes: a Dictionary containing element attributes
        - children: a List of converted child elements

def element_to_dict(elem_to_parse, element_path=None, recurse=True):
    """
    :return: an element losslessly as a dictionary. If recurse is True,
    the element's children are included, otherwise they are omitted.

    The resulting Dictionary will have the following attributes:
        - name: the name of the element tag
        - text: the text contained by element
        - tail: text immediately following the element
        - attributes: a Dictionary containing element attributes
        - children: a List of converted child elements
    """

    element = get_element(elem_to_parse, element_path)

    if element is not None:
        converted = {
            _ELEM_NAME: element.tag,
            _ELEM_TEXT: element.text,
            _ELEM_TAIL: element.tail,
            _ELEM_ATTRIBS: element.attrib,
            _ELEM_CHILDREN: []
        }

        if recurse is True:
            for child in element:
                converted[_ELEM_CHILDREN].append(element_to_dict(child, recurse=recurse))

        return converted

    return {}