Since the million-strong influx of migrants into Germany last year, authorities there have struggled to deport failed asylum seekers from Tunisia, Morocco and Algeria when their home countries refuse to take them back.
The issue has been put into sharp focus by the massive manhunt for Anis Amri, the 24-year-old Tunisian who Chancellor Angela Merkel confirmed on Thursday is the alleged perpetrator of the truck attack on a Christmas market in Berlin that claimed 12 lives.
Months earlier, Amri's asylum application was rejected but he could not be expelled from Germany because Tunisian authorities blocked the procedure.
German authorities put pressure on Tunisia, Morocco and Algeria when police established that most of the hundreds of men believed to have sexually assaulted women during New Year's Eve celebrations in Cologne hailed from those countries, but were in the country illegally.
When German authorities want to deport someone from the three countries in question, authorities in those countries insist that the individual must have a valid identity document. Without it, they cannot return.
So in order to avoid deportation, Tunisians, Moroccans and Algerians simply destroy their identity papers.
That sets in motion a long and laborious administrative process in Germany. Authorities must first make a formal request to the countries concerned to issue a temporary travel document -- and to do so they must provide proof of identity, such as fingerprints.
In the case of Amri, whose asylum request was rejected in June, this procedure took months.
Tunisia first denied that he even had Tunisian nationality before making a U-turn.
David Khalfa, an analyst from the Paris-based Institute for European Perspective and Security (IPSE), said Amri's background -- he served a jail sentence in Italy and German authorities earmarked him as a jihadist months ago -- could have dissuaded Tunisia from taking him back.
"Given his profile, it is hardly surprising that the Tunisian authorities did not really want him to return, and with Germany being a country that applies the rule of law, that threw a spanner in the works," he told AFP.
Coincidentally, the papers from Tunisian authorities to allow Amri to be deported finally arrived in Germany on Wednesday -- two days after the deadly attack on the Christmas shoppers.
Interior Minister Thomas de Maiziere visited each of the countries in question earlier this year and returned with promises that cooperation would be increased.
Overall, citizens of the three North African countries have little chance of obtaining refugee status in Germany.
Between January and November 2016, just 2.7 percent of applications from Algerians were approved, 3.5 percent from Moroccans and a miniscule 0.8 percent for those from Tunisia.
And when the numbers of asylum seekers are compared with those sent back to their homelands, the numbers are startling.
In those same 11 months this year, 3,416 Algerians, 3,829 Moroccans and 902 Tunisians applied for asylum in Germany. Yet in the first half of the year, just 56 people were sent back to Algeria, 43 to Morocco and 67 to Tunisia.
In an attempt to dissuade would-be asylum seekers from Tunisia, Algeria and Morocco, the German government decided it would classify them as "safe countries".
In concrete terms, this classification allows asylum seekers to be rejected more quickly and to assign unsuccessful applicants to an address from where they can be swiftly taken to airports to leave the country.
However, little has gone to plan.
The law easily passed through the Bundestag, or lower house of parliament, where Merkel has a comfortable majority, but it was blocked by the upper house, the Bundesrat. As a result, none of the three countries are yet classified as "safe".
In the Bundesrat, which has a markedly different composition to the lower house, the ruling coalition does not have a sufficient majority to force through the measure and needs support from the opposition that has not been forthcoming.
The Greens in particular reject the classification of a "safe" country, arguing for example that homosexuals suffer discrimination. They also point to concerns about freedom of expression and cases of torture.