Right - and apparently this is exactly what you should do. Always travel with throwaway and/or wiped devices. Don't trust a device that's been seized and returned.
It's not enough to just re-install the OS. You have to have your hardware recycled (discarded). Within a couple of seconds, they can put spyware onto your firmware by simply inserting a prepared USB device. The only way to get rid of that kind of spyware is to destroy the hardware.
The other solution is to not travel to any totalitarian countries or to travel there without any hardware, if you must.
You should not acknowledge, recognize or legitimise these 'unnatural rights'.