Ezekiel chapter 31 is addressed to Pharaoh, King of Egypt and to his hordes. It follows the prophecies in chapters 29 and 30 which describe how the Lord God would send Nebuchadnezzar, King of Babylon, and his armies (the most ruthless of nations) to destroy Egypt.
The fifth oracle, against Egypt, begins with a reminder of what happened to the might power of Assyria, which is compared to a mighty cedar tree. My New International Version Study Bible makes these comments:
Assyria – A great nation that had fallen. In 609 B.C. Pharaoh Neco went to Carchemish to help the Assyrian empire, which was reeling from Babylonian attacks. The effort failed and Assyria passed from history.
Once a Cedar – The beginning of another allegory. Lebanon – Known for its cedars. Water – The Tigris and Euphrates
The Ruler of the Nations – Probably Nabopolassar; or possibly Nebuchadnezzar
This is not a literal tree but an allegorical reference to those pagan and prideful nations who are God’s enemies. Even though Assyria and Egypt considered themselves to be invincible, God would bring them down.
This is Pharaoh, and all his hordes, declares the Sovereign Lord (Ezekiel 31:18)
It is also worth remembering that other prophecies were made against Ammon, Moab, Edom, Philistia, Tyre and Sidon (Ezekiel chapters 25, 26, 27 and 28). All of those mighty nations came under the judgment of God, hostile and pagan powers known for their cruel attacks against God’s people