Shares of Hershey (NYSE: HSY) hit a 52-week high yesterday. Let's take a look at how the company got there to find out whether the future will be as delicious for shareholders as the recent past.

How it got here
Just about everyone loves candy of some sort. You don't need any outlandish headlines to figure that out, and Hershey is a giant in the candy store. The company might not be growing rapidly, but it pays a solid dividend and should hold up well in a storm, features that have helped it post industry-leading returns over the past few years:

HSY Total Return Price Chart

HSY Total Return Price data by YCharts

Hershey's been making new highs for some time, largely because of its consistent improvements to top and bottom lines that have been paired with a flattish P/E:

HSY P/E Ratio Chart

HSY P/E Ratio data by YCharts

One thing that stands out here is a declining level of free cash flow over the last two years. This is especially troubling in light of the free cash flow gains notched by competitors over the same five-year period. We'll examine that in more detail in the next section.

What you need to know
Hershey's current P/E is 24.0, which isn't abnormal in its sector. One thing, as I mentioned earlier, stands out: lower cash flow levels. Hershey's price to free cash flow ratio is the highest of the bunch:

Company

Price-to-Free Cash Flow

3-Year Annualized Earnings Growth

Net Margin (TTM)

Hershey 45.9 15.2% 10.7%
Kraft (NYSE: KFT) 24.8 5.4% 6.5%
Tootsie Roll (NYSE: TR) 26.9 (6%) 8.3%
Archer Daniels Midland (NYSE: ADM) 6.6 (8.2%) 1.5%
H.J. Heinz (NYSE: HNZ) 16.4 2.2% 7.9%

Source: Morningstar. TTM = trailing 12 months.

Part of that discrepancy comes from larger markdowns of inventory in recent quarters. If that trend reverses itself, Hershey might easily return to a more reasonable P/FCF level. If we calculated this metric using last year's annual cash flow number, Hershey would instead have a 22.3 P/FCF, which is far more reasonable. Its dividend payout ratio is reasonable at the moment, but Hershey's free cash flow payout ratio stands at a whopping 92%. That has to come down.

Since neither Kraft nor Tootsie Roll is quite as reliant on cocoa as Hershey, they may be better insulated against cocoa price spikes that Hershey must bear if it wants to continue associating its name with "chocolate" rather than "chocolate-flavored candy products." Archer Daniels Midland and Heinz have input costs of their own to worry about, particularly that of corn. Compared to the growth of cocoa costs, corn looks downright bubbly, although until recently, it battled sugar prices for the title of "most inflated candy commodity input."

US Corn Farm Price Received Chart

U.S. Corn Farm Price Received data by YCharts

Hershey uses all three inputs in abundance (think corn syrup), but thus far has been able to pass on costs to consumers, who are still awash in an ocean of cheap junk food no matter what's happened to the cost of that junk's components. Hershey's ability to tweak product design and introduce new forms of familiar candies has helped it as well.

What's next?
Where does Hershey go from here? In all likelihood, its stock isn't in much danger. Its P/E may be high, and its P/FCF higher, but it doesn't seem likely that consumers will abandon chocolate and candy bars anytime soon. It may not be the highest yielder, but its consistent earnings growth has earned Hershey outsized long-term returns. It may not go anywhere for the second half of the year, but if your investing time frame is long enough, Hershey might still deserve a place in your patient portfolio.

The Motley Fool's CAPS community has given Hershey a three-star rating. Most of our CAPS players think the stock will go higher, and no Wall Street analyst we track has earned points by being bearish on it.

Interested in tracking this stock as it continues on its path? Add Hershey to your Watchlist for all the news we Fools can find, delivered to your inbox as it happens. If you're still on the hunt for some great dividend-paying investments, The Motley Fool's got nine great ideas for you. That's right, nine -- and they're available exclusively for our readers in a special free report. Click here to find out more about these nine rock-solid dividend stocks in our free report now.