I think this raises, indirectly at least, the very thorny issue of dual nationality. Both cases that you're referring to are of people who are of Iranian and Canadian nationality. Iran is one country that is very, very reluctant to recognize this concept of dual nationality.
It's a murky subject in international law. There is really no consensus on whether a country has an obligation to afford consular access to what it sees as its own citizen detained in their own country of origin when they happen to also have foreign nationality. One way that other countries have addressed this—and in fact Canada has done this, too—is through bilateral consular agreements. For example, this has been a problem with Chinese Canadian nationals. Canada, as well as, I think, Australia, New Zealand, the United States, and possibly some other western countries, has negotiated bilateral treaties with China, under which—and again, China doesn't recognize dual nationality—they adopt a kind of legal fiction where, provided that the Canadian enters China on their Canadian documentation, they are treated as though they were solely Canadian nationals during their time in China.
I'm not sure how encouraging it would be to open those negotiations with the Iranians, but at least it's an avenue worth exploring.