xpath = lambda state: tree.xpathEval("//daughter[@state='%s']" % state)
for nodes in zip(xpath('nice'), xpath('naughty')):
    pass
matching siblings according to tag attributes in xml using Python and libxml2