'Turn the for tags into spans and divs, and apply data attrs.
If a for contains any block-level elements, it turns into a div.
Otherwise, it turns into a span.'

def expand_fors(self):

    html_ns = 'http://www.w3.org/1999/xhtml'
    for for_el in self._root.xpath('//html:for', namespaces={'html': html_ns}):
        for_el.tag = ('div' if any(((for_el.find(((('{' + html_ns) + '}') + tag)) is not None) for tag in BLOCK_LEVEL_ELEMENTS)) else 'span')
        for_el.attrib['class'] = 'for'
