The recent Panama Papers leak revealed how global elites use offshore companies to avoid paying taxes, but that isn't the only reason they're sheltering their wealth. The rich are also sending money abroad to keep it away from their future exes.

"Every now and then I get a call from someone saying, 'I'm thinking about getting a divorce in five years. Can you help me protect my assets in case I get one?'" said Randall Kessler, an Atlanta divorce lawyer and former chair of the Family Law Section of the American Bar Association. "That presents us with a problem."

Kessler said he doesn't help clients hide their money offshore. After all, it's illegal to help someone evade taxes or conceal their assets from a judge in the event of a divorce.

But unscrupulous lawyers will do so, the Panama Papers showed. The 11.5 million documents leaked to the press from the Panamanian law firm Mossack Fonseca detail numerous examples of high-fliers seeking to make sure their soon-to-be ex-wives and husbands don't obtain half of their fortunes after a breakup.

"For decades, spouses — nearly always male and part of the global One Percent — have solicited Mossack Fonseca to help shield assets from soon-to-be exes," says a report from the International Consortium of Investigative Journalists, or ICIJ, the American group that coordinated a worldwide effort to report on the Panama Papers. "Mossack Fonseca has agreed with little hesitation."

Mossack Fonseca representatives told the German newspaper Süddeutsche Zeitung that they "regret any misuse of the companies we create or services we offer. Wherever possible we take steps to either uncover or stop such misuse."

The law firm has also complained that a hacker illegally stole the documents. Süddeutsche Zeitung was the first media organization to obtain the Panama Papers, but neither the newspaper nor the ICIJ has released the documents to the public.

The case of Dmitri Rybolovlev, a mining magnate whom Forbes listed as the 148th richest man in the world, is the perhaps most spectacular of the examples related to divorce in the Panama Papers.

His wife Elena filed for divorce in 2008 after a 23 year marriage during which the couple amassed a gargantuan fortune including assets such as a $60 million yacht named My Anna, an $88 million penthouse in New York City, and paintings by Pablo Picasso, Vincent van Gogh, and other famous artists, the outlets reported.

A network of offshore companies had been set up by the couple, including Xitrans Finance Ltd — a firm incorporated in the British Virgin Islands by Mossack Fonseca which bought and stored art works and antique Parisian furniture worth $650 million. According to court documents emailed to Mossack Fonseca in January 2009, as the marriage broke down Rybolovlev used Xitrans Finance to move some of the luxury items out of Switzerland, where the couple lived. Under Swiss law, she would be entitled to half their fortune — but only that which the court knew about.

Rybolovlev was also the only shareholder in Xitrans Finance, despite the company being held by the Rybolovlev family trust and despite Elena's claim that Xitrans bought assets "on behalf of herself and her husband," wrote the ICIJ.

A Swiss court ordered Rybolovlev to pay Elena $4.5 billion last year, which was later reportedly slashed to $600 million. The courts never determined if Rybolovleva was committing fraud by hiding assets in divorce proceedings. In a statement following the Panama Papers release, Rybolovlev family's lawyer said the description of the divorce in the Panama Papers reporting was misleading and his client "has never used any offshore entity to conceal any assets."

Other examples of matrimonial foul play cited in the leaked documents include a Mossack Fonseca employee asking if an "old-fashioned trust fund" could hide money for a Dutchman whose divorce was "on the horizon," and a Peruvian woman who set up shell companies to hide an inheritance from her husband, Süddeutsche Zeitung reported.

For Americans, hiding money offshore in hopes of keeping it from a potential ex-spouse is especially dangerous, noted Barry Sziklay, a New Jersey-based forensic accountant who helps clients find their estranged spouses' offshore funds.

Americans are supposed to register their foreign assets with the US government so that they can pay their fair share of taxes on them, Sziklay explained. They also must disclose all their assets in divorce court, otherwise they are breaking the law. Anyone who has been hiding money offshore must choose between lying about it in divorce court and suffering the consequences if they're caught, or fess up to owning the foreign assets and then answer to the Department of Justice and Internal Revenue Service.

Rich people sometimes gamble on hiding away their funds, however, often because they're behaving irrationally and vindictively as their marriage falls apart, according to attorney John Slowiaczek, president-elect of the American Academy of Matrimonial Lawyers.

"Generally, people who engage in what we will say is this bad behavior are greedy, devious, narcissistic, manipulative, sociopathic," he said. "All the traits that sometimes make a very successful and valuable businessman or woman are traits that don't often make a good spouse. The thought process is, I've gotten away with a lot of bad things, and I can get away with this one."

Of course, it's possible to move money or own assets abroad legally. And American judges often can't order foreign banks or governments to give up assets held by American customers. In those cases, the court might order the spouse who owns the foreign assets to release the money him or herself. If they refuse, they can face steep fines and jail time.

"People talk about doing jail time like it's going on vacation," said Sziklay. "It's not vacation, especially for white-collar criminals. You put them in jail and you'll be surprised by how quickly they break. It's a pretty scary place for the typical white-collar guy."

Other times spouses in divorce proceedings use multiple trusts, shell companies, and other legal machinations to make it hard and expensive for the court and spouse to track down the money, explained Kessler. Sometimes that leads people to negotiate a divorce settlement that brings the costly and emotionally draining fight to an end.

"The person going through a divorce says, 'What can I do to end this now?'" said Kessler. "There is something invaluable in divorce. And that something is closure."

Developments like the Panama Papers leak and the US government's crackdown on American customers of Swiss banks should have convinced wealthy people by now to declare their foreign funds, said Michael Sardar, an attorney at the New York law firm of Kostelanetz & Fink who specializes in helping clients approach the US government to disclose their illegal foreign accounts.

But Sardar knows some people don't take his advice for various reasons — including because they think their husband or wife will someday want to take half of their hard-earned riches.

"If nobody knows about it, and nobody finds out about it... The problem is, how well can you sleep?" asked Sardar. "Every year you file that tax return, there's that question. Do you have a foreign account? Each year you say no, it's harder to conceal that from the IRS. Every year, you're magnifying and increasing the problem."