def getOptionalAttribute(element, attribute):
    """Return the value of an *attribute* from an *element*,
    but do not crash/throw if *attribute* does not exist.

    Return None if *attribute* is not in the parent *element*.

    :param element: the parent element that (might) contain(s) the attribute
    :param attribute: the optional attribute to return the value of
    """
    if element.hasAttribute(attribute):
        return element.attributes[attribute].value
    else:
        return None