NEW YORK (TheStreet) - Berkshire Hathaway (BRK.A) - Get Report may have avoided about $400 million in taxes by exiting its long-time stake in Graham Holdings (GHC) - Get Report - formerly known as The Washington Post Company - through an asset swap with the company that will add Miami-based TV station WPLG and hundreds of millions in cash to Berkshire's coffers. Wednesday's transaction also may also break new ground in how large investors structure deals to avoid taxes on their investment gains.

Berkshire's deal with Graham Holdings is structured in a way that may allow the Warren Buffett-run conglomerate to exit a multi-decade investment in Graham Holdings without paying any capital gains tax, Robert Willens, an independent tax expert, said in a Friday telephone interview.

And Berkshire certainly gained from its Graham Holdings investment.

The cost-basis for Berkshire's 1,727,765 million shares was $11 million, Warren Buffett said in Berkshire's 2000 annual letter to shareholders. Now, Berkshire is seeking to exit Graham Holdings at a value in excess of $1.1 billion.

Applying a 38 percent tax rate (federal plus state and local taxes) would bring Berkshire to about $400 million in tax liability, Willens said. The swap orchestrated between Berkshire and Graham Holdings, however, is likely to reduce Berkshire's tax liability to $0.

On Wednesday, Berkshire Hathaway and Graham Holdings agreed to a deal where the Warren Buffett-run company will acquire WPLG, cash and Graham Holdings shares in Berkshire Hathaway in exchange for Berkshire's 1.6 million share stake in the former owner of The Washington Post.

The Miami TV station will be valued at $364 million, and Graham Holdings will fork over $327.7 million in cash and $400.3 million worth of Berkshire shares, as part of the deal, according to an 8-K filing with the Securities and Exchange Commission. Berkshire Hathaway will retain between 91,490 and 111,716 shares in Graham Holdings depending on the trading prices of both firms as the exchange closes.

"The story here is that Berkshire is avoiding about $400 million in tax liability they would have incurred if they had done a direct swap," Willens said.

The mechanics of Berkshire's maneuvering are arcane, especially since both Berkshire and Graham Holdings hold large investment gains on each other company's shares. Berkshire holds 1,727,765 Graham Holdings shares, while Graham Holdings owns 2,214 shares in Berkshire's Class A stock.

To unwind each other's investment, Berkshire and Graham Holdings devised what amounts to a stock swap, although not a direct swap that would have locked in capital gains on both companies' respective investments.

"[W]hen the dust settles, the parties will have accomplished their unwinding objectives, but will have done so without tax consequences," Willens said in a Thursday note to his clients.

Berkshire and Graham Holdings will effect what is called a "cash rich split off" by creating a subsidiary, called "NewSub," that will execute the exchange of the TV station, hundreds of millions in cash, and stock between both parties.

Eventually, Berkshire will control 100% of NewSub's assets, and Graham will receive 1.6 million of its shares from Berkshire.

Normally, both corporations and investors must recognize taxable gains on appreciated assets, even if they transfer shares for assets such as cash or business lines.

But Berkshire isn't directly taking the TV station from Graham, and Graham isn't taking Berkshire's stock. NewSub is doing all of the stock, TV station and cash swapping. As such, the swap may meet Sec. 355 of the federal tax code that exempts capital gains.

"The Exchange is intended to qualify for non-recognition of gain and loss to Graham and to BH under Sections 355(a), 355(c), 361(a) and 361(c) of the Code," Berkshire Hathaway said in a filing with the SEC.

The most important element to qualifying for Sec. 355 in the case of Wednesday's deal is that the Internal Revenue Service won't see NewSub's assets as being comprised two-thirds or more of investment assets, a disqualified investment corporation. Investment assets in the swap would include the $327.7 million in cash and the $400.2 million in stock Graham will transfer to Berkshire by way of NewSub.

Because Graham and Berkshire will place a $364 million value on WPLG and the value of the stock and cash that comprise the rest NewSub won't exceed $728 million, investment assets are unlikely to exceed the IRS's the two-thirds threshold.

"The I.R.S. certainly has an interest in showing that the value of the TV station is less than $364 million. If it is less than $364 million, NewSub might be treated as a disqualified investment corporation," Willens said.

If Warren Buffett's tax lawyers and bankers earn their fees, NewSub won't be considered a disqualified investment corporation that would be liable for capital gains tax.

"This particular cash-rich split-off breaks new ground since, to our knowledge, it is the only one in which the investment assets of the distributed subsidiary consist, at least in part, of the stock of the very shareholder to whom the subsidiary's stock is being distributed," Willens wrote on Thursday.

Buffett and The Tax Debate

Berkshire's swap deal with Graham Holdings and similar moves the investment conglomerate has made in exiting large investments in Phillips 66 (PSX) - Get Report and White Mountain Insurance (WTM) - Get Report indicate that Warren Buffett isn't interested in paying taxes on Berkshire's investment gains when cutting deals on behalf of the company's shareholders.

That comes as Buffett has placed himself front-and-center in a debate over taxation that has simmered in Washington for decades.

Buffett coined the so-called 'Buffett Rule,' which would create a flat tax for top income earners, after he famously noted that his secretary Debbie Bosanek often pays higher income tax rates than him. Buffett, as of Thursday was the second-richest person in the world, while Bosanek, by all accounts, makes a middle class salary.

Even in pursuing tax-free investment disposals, Buffett may buffer himself from accusations of hypocrisy. The Buffett Rule is intended to breed more progressive income tax rates, and has little to do with corporate taxation or capital gains.

A New Strategy for Berkshire

As TheStreet noted on Wednesday, Berkshire's deal with Graham Holdings may shed light on a new strategy that Warren Buffett may employ when exiting the firm's best investments. While Berkshire has taken assets from the likes of Graham, Phillips 66 and White Mountain, the company is yet to use a swap maneuver on its largest investments.

Were Berkshire to employ an in-direct swap as a means to exit any of Berkshire's big-four investments, it would be a major story for Corporate America.

As of 2013, Berkshire is sitting on over $12 billion in unrealized gains on its stake in American Express (AXP) - Get Report, over $15 billion in unrealized gains on its stake in Coca-Cola (KO) - Get Report and about $10 billion in unrealized gains on its stake in Wells Fargo (WFC) - Get Report.

Maybe at some point in time, there will be parts of each of those businesses that Buffett would be willing to own in lieu of Berkshire's stockholding.

Berkshire's investment in Procter & Gamble (PG) - Get Report, Moody's (MCO) - Get Report, and Goldman Sachs (GS) - Get Report and Bank of America (BAC) - Get Report stock warrants also stand out as among Buffett's best returning investments.

Bottom Line: Warren Buffett is pioneering new ways to avoid capital gains tax, even as he is President Obama's richest spokesperson for progressive income tax policy.

-- Written by Antoine Gara