def remove_child_nodes(parent, except_id=None):
    """Remove all child nodes from parent except for that with `except_id`"""
    skipped_node = None
    victims = parent.childNodes
    while len(victims) > 0:
        for node in victims:
            if except_id:
                try:
                    if node.getAttribute('id') == except_id:
                        skipped_node = node
                except AttributeError:
                    pass
            parent.removeChild(node)
    if skipped_node:
        parent.appendChild(skipped_node)
