U.S. President Donald Trump and North Korean leader Kim Jong-Un are playing a dangerous game of brinkmanship.

North Korea got the world’s attention — and Trump’s — when it successfully launched an intercontinental ballistic missile for the first time on July 4. In response, the United Nations approved new economic sanctions against North Korea which, predictably, inspired a bellicose response from the rogue regime.

Trump threatened that further provocations will be met with “fire and fury and frankly power, the likes of which this world has never seen before.”

In response, North Korea issued a threat of its own — missile strikes on the U.S. territory of Guam.

Read:How Trump’s threat of ‘fire and fury’ is rattling stock-market calm

With tensions escalating, it is important to be realistic about how we can get out of this mess.

In short, any nonmilitary solution will rely on China choosing to apply its massive economic leverage over the North Korean regime. This is a point that Trump clearly recognizes. In July, he tweeted that Chinese trade with North Korea “rose 40% in the first quarter,” highlighting China’s reluctance to punish North Korea for its pursuit of nuclear weapons.

While the poor quality of the data on trade between these countries hinders a detailed analysis, Trump’s overall sentiment is correct. China has increased its trade with North Korea in recent decades and has done little to forestall North Korea’s nuclear ambitions besides backing the most recent round of U.N. sanctions. China’s foremost objective seems to be promoting greater stability from its volatile neighbor.

Yet a quick look at the data, however murky, shows just how much leverage China has, if it wishes to use it.

North Korea’s primary patron

In general, exports from one country to another can be mostly explained by the distance between them and the sizes of their markets, a pattern that holds for China and North Korea.

Geographically, they share a large border, which makes China a natural, though not inevitable, partner for trade. As a case in point, North Korea also shares a long border with South Korea, but these countries have almost no trade between them. In addition, North Korea shares a small border with Russia, with whom it has little, though ever-increasing, trade, as I discuss below.

China’s large market, proximity and — most importantly — willingness to trade with North Korea has led to a situation in which North Korea has become highly dependent on trade with what has become its primary patron. About half of North Korean exports and imports go directly to and from China and most of the rest of its trade is handled indirectly by Chinese middlemen.

North Korea’s dependence on its northern neighbor has grown hand-in-hand with China’s increasing economic dominance of East Asia, which gained momentum 15 years ago when China joined the World Trade Organization. Since then, both Chinese gross domestic product as well as its annual trade with North Korea have increased nearly tenfold, to around $11 trillion and $6 billion, respectively.

North Korea imports pretty much everything from China, from rubber tires to refined petroleum to pears, with no single category dominating. Meanwhile, coal constitutes about 40% of its exports to China, followed by “non-knit men’s coats.”

Time to use that leverage?

However, recent events — such as the use of front companies by Chinese firms to evade sanctions imposed on North Korea and China’s reluctance to cut off energy supplies to the country — have led to some uncertainty about the extent to which China is willing to use this economic leverage to rein in North Korea’s military ambitions.

Read:U.S. warns North Korea only ‘self-restraint’ is preventing war

On the one hand, China claims that coal imports from North Korea have recently been stopped as part of an effort to punish the regime for recent missile tests and the suspected assassination of Kim Jong-nam, the estranged half-brother of North Korean leader Kim Jong Un. If true, this would be an important signal of China’s willingness to support U.S. concerns about the missile program as it would represent a loss of about a third ($930 million) of North Korea’s import revenue.

However, there is evidence that coal shipments in fact never ceased. And in any case, China may have dramatically increased its imports of iron ore from North Korea to offset the lost coal revenues.

“ One way or another, China must become convinced that the costs of propping up the North Korean regime through trade are higher than the costs of an increased probability that the regime will collapse. ”

This is consistent with the idea that China carefully considers the resources and revenue that are available to the North Korean regime at any moment, and uses trade as a lever to control them. In this way, China walks a fine line between providing too many resources, and thus allowing the regime to prosper, and not enough resources, such that North Korea is in danger of collapsing. Ultimately, trade may be used as a lever to do some light scolding, but China’s overwhelming concern is preventing North Korea’s collapse.

Further evidence that China has tight control over the North Korean economy comes from a recent report from C4ADS. The research group found close, and often common, ownership ties between most of the major Chinese companies who do business with North Korea. This suggests that trade with North Korea is highly centralized and thus easily controlled.

Russia: North Korea’s other ‘friend’

Of course, China’s not the only country North Korea trades with, but the others pale in comparison. Other top export destinations, after China, include India ($97.8 million), Pakistan ($43.1 million) and Burkina Faso ($32.8 million). In terms of imports, India ($108 million), Russia ($78.3 million and Thailand ($73.8 million) currently sell the most to North Korea.

Russia in particular may be beginning to complicate things for U.S. efforts to isolate the regime. While still little, Russian trade with North Korea increased 73% over the first two months of 2017 compared with the same period of the previous year.

But whereas China is legitimately worried that an economic crisis in North Korea could lead to a flood of refugees or all-out war, Russia likely sees engagement with North Korea in much simpler terms, namely as an additional way to gain geopolitical advantage relative to the U.S.

Is North Korea close to being a nuclear-weapons state?

A way out?

Nearly all experts agree that there is no easy way to “solve” the North Korea problem. However, one plausible approach is to encourage South Korea and Japan to begin to develop nuclear weapons programs of their own, and to only discontinue these programs if China takes meaningful steps to use its trade with North Korea to reign in the regime.

Threatening to introduce new nuclear powers to the world is clearly risky, however stable and peaceful South Korea and Japan currently are. But China is highly averse to having these economic and political rivals acquire nuclear capabilities, as it would threaten China’s ongoing pursuit of regional control. In short, this is a sensitive pressure point that could be used to sway the Chinese leadership.

One way or another, China must become convinced that the costs of propping up the North Korean regime through trade are higher than the costs of an increased probability that the regime will collapse.

Greg Wright is an assistant professor of economics at University of California, Merced. This is an updated version of an article originally published on The Conversation on July 6 and on MarketWatch July 7.