The election of Donald Trump is part of an ongoing surge of right-wing nationalism across the globe, from Brexit to Hungary to the Philippines.

This presents a thorny problem for the left. Belligerent nationalism has caused many of the worst atrocities in modern history, from the Black Hand in Serbia to Nazi Germany. Yet the basic political instincts behind nationalism cannot simply be ignored or wished away.

If it is to defuse the more destructive aspects of nationalism, the left must admit the need for national fellow feeling — and ensure that, unlike the eurozone, any supranational institutions are created on a democratic basis.

Human beings evolved in small bands of a few dozen individuals. But today we live in nations of millions and millions of people. The problem of politics in such a vast society is to organize some principle by which citizens will be loyal to the state, obeying the law and following social norms. How do you create fellow feeling among citizens when the vast majority will never meet or even hear of each other?

The right-wing nationalist way is by imagining a nationwide community whose organizing principles are arrogant superiority and a right to dominate others. These are the United States of "America First" and "freedom fries" and "Courtesy of the Red, White, and Blue" and "Make America Great Again." (These formations often try to dominate other internal groups as much as they are directed outwardly at different nations.)

But one could also harness the same instinct towards a much more decent set of beliefs — a national community organized around principles of equality, freedom, and warm feeling towards one's fellow citizens. Such an American identity might be centered around the Declaration of Independence, the Reconstruction Amendments, the Statue of Liberty, and the New Deal.

Such a left-wing nationalism would recognize the moral personhood of all humans, but it would also recognize the limits of American power. It is just an inescapable fact that the United States can't help everyone in need around the world. Attempting to impose democracy by force results in bloody catastrophe. Even simple economic aid has often backfired.

That is why allowing immigration — particularly that of helpless refugees — would be a high priority under this type of nationalism. It's far easier to allow suffering people to join a functioning nation than to micromanage the politics of some far-off place.

But here, too, one must recognize the state's limitations. America is a vast nation with deep experience in accommodating new residents. We take on roughly one million immigrants every year, something that could no doubt be scaled up three- or four-fold without much strain (particularly in a time of declining birthrates). But it could not be scaled up 1,000-fold without causing disaster.

So what should be the long-term goal? One might imagine a far-off utopia where national fellow feeling gradually evolves into a universal fellow feeling encompassing the entire planet and a single world government, like the Federation of Star Trek. But the only way I see of getting there is through a process of careful evolution where democratic legitimacy is respected at every stage.

Take the eurozone, for example. This is by far the largest experiment in dissolving nationalism ever attempted. The idea was a quite deliberate attempt to put the economic cart before the democratic horse. By going for a common currency before a fiscal or banking union, the countries of the eurozone would be forced into an ever deeper union ending in some sort of pan-European state.

Instead, it's been one of the all-time worst policy disasters in world history, and had the polar opposite of its intended effect.

The eurozone — which all EU members save a couple are obligated to join eventually — has become a brutal economic tyranny run by a handful of technocrats in the core countries, who deliberately created full-blown depression conditions in many periphery countries with austerity and tight money. The result has been a rebirth of nationalism of both left and right-wing stripes. So far the only significant left-wing rebellion, in the form of Greece's Syriza, has been strangled, as it's much easier to defeat someone who tries to negotiate in good faith. Fascists in Greece and other countries have watched and learned — and will not be so easily put down.

So perhaps the various nations will someday slowly disappear into an egalitarian species-state spanning the whole world. But for now, the nation-state is simply unavoidable — and any future supranational institutions (such as Keynes' idea for an "International Clearing Union" to manage world currency and trade) must be directed by the informed consent of the affected nations, not jammed through with coercion and deception.

Without a consistently human and democratic left-wing nationalism, a violent and hateful right-wing one will take its place.