Issue #16076: fix refleak in pickling of Element.

Thanks to Ezio Melotti and Daniel Shahaf for the patch.