'Replace the node only if it can have a data-if added to it.
This is because nodes that have a data-if or data-else are left
in-place and new wrappers were generated in copy_node.'

def replace_node(self, orig_node, node):

    if (not self.match_keys):
        return orig_node
    if self.can_have_if(orig_node):
        return super(IfElseFilter, self).replace_node(orig_node, node)
    else:
        for child_node in orig_node.iterchildren():
            orig_node.remove(child_node)
        orig_node.text = ''
        orig_node.append(node)
        return node
