function getAncestorOfTagType(elem, type) {
    while (elem.parentNode && elem.tagName !== type) {
        elem = elem.parentNode;
    }

    return (type === elem.tagName) ? elem : undefined;
}
Get the first ancestor node from an element, having a
certain type.

@param elem An HTML element
@param type an HTML tag type (uppercased)

@return An HTML element