Plans for the recapture of Mosul, Iraq's second largest city, from the so-called Islamic State are fiendishly complicated.
Ethnic rivalries, as well as sectarian and religious sensitivities, will have to be respected if the offensive is not to go horribly wrong.
The Iraqi army which scattered and fled as IS fighters drove and rode into Mosul in 2014 was mocked as I.R.A.Q. or I Ran Away Quickly.
But the soldiers may have been running not only from IS.
The mostly Sunni Arabs of Mosul resented the domination of the central Baghdad government by Shia Muslims.
Junior ranks in the Iraqi army were afraid that they would be attacked by Sunni Arabs in Mosul as well as IS, taking revenge for the transformation of Iraq into what they perceived to be a Shia state.
For the same reason, IS in Mosul has enjoyed strong political and logistical support from former members of Saddam Hussein's Baathist armed forces, men who were summarily dismissed and who lost their livelihoods in the de-Baathification process after 2003.
The sectarian policies of the first elected prime minister Nouri Maliki may have led some Mosulites to welcome "Islamic State".
The Shia government in Baghdad had allowed the pendulum of political adjustment in Iraq to swing so far that the large Sunni minority felt downtrodden, marginalised, and collectively blamed for Saddam Hussein's cruelty towards the Shia majority.
But the new prime minister Haider al-Abadi - also Shia of course - has worked hard to bring Sunnis back into the fold.
For example, he has funded and armed Sunni Arab tribal forces which are expected to play a prominent role in the imminent battle for Mosul.
The remaining residents, especially in the city centre, are more likely to welcome them than the mostly Shia Iraqi army, the irregular Shia "Popular Mobilisation Forces", or the Kurdish Peshmerga.
Meanwhile the remaining IS fighters have driven out, or massacred, the Christians, Yazidis and Kurds who used to live there.
Thousands of Sunni Arabs too have also left Mosul.
If they ever believed that IS was a potentially sympathetic group of Sunni co-religionists, they were quickly disabused as the conquerors of Mosul revealed themselves to be irrational psychopaths who, for example, force children to watch public executions.
Hundreds of thousands of people - possibly a million - are expected to flee Mosul ahead of the forthcoming battle.
As IS still occupies Tal Afar to the west and Hawija down the Tigris to the south, most fleeing families are likely to go east towards Irbil in Iraqi Kurdistan.
Extra pontoon bridges have been installed across two rivers on that route, and some refugee camps have been prepared.
But it's not clear if Iraqi Kurdistan can really cope with a mass exodus from Mosul, or with columns of refugees who may have IS fighters concealed among them.
Between 3,000 and 5,000 IS fighters remain in Mosul, the Pentagon says, while the number of Sunni Arab tribal fighters ready to fight them there and in nearby towns is estimated at between 7,000 and 10,000.
Approximately half of them have been trained by Turkish forces based at Bashiqa, a military camp between Mosul and the Turkish border.
There are also Turkish troops on the ground in northern Iraq - and some Turkish tanks too - thanks to an agreement with the Kurdish regional government; but not by agreement with the government in Baghdad.
This has led to a tetchy exchange between Baghdad and Ankara.
One of Turkey's objectives is to prevent consolidation of power by Kurds in this strongly Kurdish corner of the Middle East.
There are about 150,000 Kurdish Peshmerga fighters available for the recovery of Mosul, but only 2,500 trained and ready for battle.
The United States recently agreed to give the Peshmerga $415m (£340m) to pay their soldiers, and to buy fuel, food and ammunition.
They have also supplied some heavy weapons - but not enough, according to Iraqi Kurdish commanders.
There are also about 5,000 American forces in Iraq now, many of them from the 101st Airborne Division which occupied Mosul in 2003.
Others are believed to be special forces, many of them training and supporting thousands of Sunni tribal fighters.
Ten years ago, the Americans helped Sunni tribal leaders in Anbar province west of Baghdad form the 'Awakening' movement to defeat a previous incarnation of violent fundamentalist Islam - al-Qaeda in Iraq.
After US troops mostly left Iraq, it was the failure of the Maliki government to continue supporting the Awakening which helped the self-styled Islamic State move in and and occupy key cities like Ramadi, Fallujah, Tikrit... and Mosul.