Source: Motley Fool.

Warren Buffett's Berkshire Hathaway (BRK.A -0.11%) (BRK.B -0.05%) recently announced an agreement to purchase Duracell from consumer goods giant Procter & Gamble (PG -0.20%) via a stock swap. While most analysts are focusing on the rationale for buying the battery business, the fact that Berkshire Hathaway is completely selling its stake in Procter & Gamble could be just as important when it comes to understanding the reasons behind this deal.

Buying Duracell or selling Procter & Gamble?
Procter & Gamble is recapitalizing Duracell with approximately $1.7 billion in cash. Berkshire Hathaway will then exchange its Procter & Gamble shares, worth roughly $4.7 billion at current prices, for full ownership in Duracell. The deal is expected to close in the second half of 2015.

Being structured as a stock swap, the deal saves a lot of money on taxes. Procter & Gamble is carried on Berkshire Hathaway's balance sheet at a cost of nearly $336 million; if done in cash, this deal would generate a huge tax bill because of the impact of taxes on long-term capital gains.

Selling the Procter & Gamble stake seems to be the main reason for the recapitalization of Duracell with fresh cash, which increases the size of the deal to Berkshire Hathaway's entire position in Procter & Gamble. If not for this recapitalization, Buffett could have maintained part of his position in Procter & Gamble, but in this case the Oracle of Omaha seems to prefer cash.

Buffett rarely sells any of his big positions, but Procter & Gamble has been a notorious exception in recent years. From a stake of nearly 101.5 million shares in 2007, Berkshire Hathaway has reduced its ownership in Procter & Gamble to nearly 52.5 million shares as of now.  

In a 2012 interview with CNBC, Buffett provided some insight regarding his position on Procter & Gamble: "Frankly, the earnings on Procter & Gamble have been disappointing now for a few years."

Time to sell Procter & Gamble?
Buffett's decision to sell Procter & Gamble might understandably raise some eyebrows among the company's other investors. However, blindly following the moves of other investors is hardly a sound investment strategy, not even when it comes to one of the most successful investors ever.

To begin with, even the best investors make mistakes, both when buying and selling stocks. As an example, Buffett admitted quite straightforwardly that his decision to sell McDonald's stock in 1998 was an expensive error. In his own words from Berkshire's 1999 annual letter:

I need to make a confession (ugh): The portfolio actions I took in 1998 actually decreased our gain for the year. In particular, my decision to sell McDonald's was a very big mistake. Overall, you would have been better off last year if I had regularly snuck off to the movies during market hours.

Besides, different investors have their own targets and strategies. Just because Buffett doesn't like a stock for Berkshire Hathaway's portfolio does not mean the company is necessarily a bad choice for other investors.

Procter & Gamble is a dividend powerhouse that has increased its payouts for 58 years in a row. In addition, management is selling underperforming brands to focus on its most promising names in its portfolio. Sometimes less is more, so a smaller Procter & Gamble could also be more flexible and dynamic.

Trading at a dividend yield near 2.9%, Procter & Gamble doesn't seem overvalued at all, so the case for selling the stock is not obvious.

Still, regardless of the reasons, Buffett did not just want to buy Duracell. He most likely wanted to sell Procter & Gamble, too. In his usual brilliance, he did both things at the same time, while saving tons of money in taxes.