def get_xsi_type(element):
    """
    returns the type of an element of the XML tree (incl. its namespace),
    i.e. nodes, edges, layers etc.), raises an exception if the element has no
    'xsi:type' attribute.
    """
    nsdict = NAMESPACES
    #.xpath() always returns a list, so we need to select the first element
    try:
        return element.xpath('@xsi:type', namespaces=nsdict)[0]
    except IndexError:  # xpath result is empty
        raise ValueError("The '{0}' element has no 'xsi:type' but has these "
                         "attribs:\n{1}").format(element.tag, element.attrib)
returns the type of an element of the XML tree (incl. its namespace),
    i.e. nodes, edges, layers etc.), raises an exception if the element has no
    'xsi:type' attribute.