When done right, a stock buyback can be a beautiful thing. Management teams can deploy excess cash that's earning next to nothing to buy higher returning assets, hopefully at a big discount. The problem is that most management teams simply aren't very good at timing stock buybacks.

With a recent announcement to buy back up to $2 billion of its own shares, Apache (APA -0.03%) is just one of the latest companies joining the buyback parade. The company will soon have some extra cash at its disposal as it's planning to unload as much as $4 billion in assets. In essence, what the company is doing is selling the assets it likes least so it can own more of what it likes best.

While it remains to be seen what assets Apache will part with, once it is able to unload these assets, it plans to use about half of the proceeds to buy back around 30 million shares in addition to reducing its debt by about $2 billion. That would enable the company to trim its debt-to-equity ratio from about 39% closer to 33%. Both appear to be solid moves, especially when you consider that the company is buying back 7.5% of its outstanding shares.

The question, though, is whether the company is buying back its stock because it needs to do something with the deal proceeds or if it sees value in its stock. For that, let's take a look at the following chart ,which compares Apache to its peer group of large-cap independent E&P companies:

Source: Occidental Petroleum Investor Presentation (opens in a PDF).

As you can see, Apache trades at a pretty compelling discount to its large-cap E&P peers like Devon Energy (DVN -0.89%) and Occidental Petroleum (OXY -0.09%), which trade at about 5.5 times estimated 2013 EBITDA. By trading at just four times EBITDA, Apache is in line with ConocoPhillips (COP -0.43%), though it's still not nearly as cheap as Marathon Oil (MRO -1.04%).

In shedding assets and announcing the buyback, Apache is looking to unlock some value in order to bump its value closer to the 5.5 times that both Devon and Occidental are trading. What could that mean for investors? Given that shares are currently around $85 per share, that would imply that shares are worth upwards of $120 per share, meaning the stock could be 40% undervalued. Clearly, the buyback makes a lot of sense.

Why is Apache so cheap? Unlike Marathon and Conoco, it hasn't repositioned by jettisoning refinery assets, which could explain why those stocks are so cheap. On the other hand, it is clearly a dominant North American liquids-focused onshore driller so it's surprising that it doesn't trade more in line with Devon or Occidental Petroleum.

The biggest difference between Apache and its peers appears to be the fact that Apache is the No. 1 oil producer in Egypt, which brings both volatility and uncertainty. The market clearly seems to be discounting the company's value because of these assets despite the fact that Egypt delivered $2.7 billion in cash flow last year. Not only that but Apache has seen 17 years of uninterrupted production growth and is investing $1.1 billion in the country this year to continue to grow production. What worries investors is the risk that its position in Egypt could end badly. 

I think it's highly unlikely that Apache pursues a similar path as Devon, which has spent the past few years selling off its international operations to focus on its North American onshore business. Apache isn't likely to get anywhere near the full value of its international assets by selling them. It's better off just reinvesting the cash generated from those assets to buy back its cheap stock.

One area to watch, however, is Occidental's plan to split its U.S. and international assets into two separate companies. Some suggest that the $74 billion market-cap company could unlock up to the $47 billion in value by splitting the company. That could cause a wave of similar transactions, which is exactly what happened when both Conoco and Marathon split off their respective refining businesses. It's a wave that could eventually hit Apache. 

As an investor, there is clearly a lot of potential value to be unlocked in Apache's stock. Its management team is making the right move in buying back its stock as Apache looks like a fairly compelling value right here. As an investor, if you are looking for value, Apache is a good company to buy. Not only that but you'd be in good company as this billionaire just bought shares, too.