RemoveElement and RemoveAttrByKey tweaks.
RemoveElement clears the removed element's parent pointer.
RemoveAttrByKey APIs return a pointer to (a copy of) the removed attribute.