"""
for motif in doc.findall('//strofa//motyw'):
# find relevant verse-level tag
verse, stanza = motif, motif.getparent()
while stanza is not None and stanza.tag != 'strofa':
verse, stanza = stanza, stanza.getparent()
"""
for motif in doc.findall('//strofa//motyw'):
# find relevant verse-level tag
verse, stanza = motif, motif.getparent()
while stanza is not None and stanza.tag != 'strofa':
verse, stanza = stanza, stanza.getparent()