etree actually does have a way to distinguish Elements and ProcessingInstructions. You can check to see if problemtree.tag is an etree.Comment or an etree.PI

if problemtree.tag is etree.Comment or etree.PI:
    return