The challenge with detaching the parent container as you would need to put it back where you got it from. A way of dealing with that is to determine if there is a sibling and then using before or after to put it back in. Alternatively you could clone, work on the clone then replace.