def element_path(elt):
    """
    Walk up the XML structure from the given element, producing a tuple with the
    names of the region, sector, subsector, technology, and input found in this
    "path".

    :param elt: (lxml.etree.Element) an "input" element to start from
    :return: tuple of strings: (region, sector, subsector, technology, input)
    """
    input = elt.attrib['name']
    sector = subsector = technology = region = None

    for node in elt.iterancestors():    # walk up the hierarchy
        tag = node.tag
        attr = node.attrib

        if tag == 'period':
            continue

        elif tag == 'location-info':
            sector = attr['sector-name']
            subsector = attr['subsector-name']

        elif tag == 'region':
            region = attr['name' ]
            break

        elif tag == 'supplysector':
            sector = attr['name']

        elif tag in ('stub-technology', 'technology'):
            technology = attr['name']

        elif tag in ('subsector', 'tranSubsector'):
            subsector = attr['name']

        elif tag in ('global-technology-database'):
            break

    return (region, sector, subsector, technology, input)