The best stock buy can sometimes be the least obvious.

Normally, if oil's getting more expensive, you'd figure you should buy dominant petroleum companies such as ExxonMobil (NYSE: XOM) and ConocoPhillips, as superinvestor Warren Buffett did. Or perhaps you'd pursue companies more focused on exploration and production, as my Foolish colleague Dan Dzombak did, when he called one E&P a "double-bagger."

But for all the wisdom in these picks, there are also more subtle ways to play the rising price of energy. Furthermore, these methods can powerfully leverage other growing economic trends, creating lollapalooza stock returns. The small-cap stock I'll discuss today can do exactly that -- but before I introduce it, let me explain why this type of unexpected play can be more effective.

Buy it like Buffett
Berkshire Hathaway
's (NYSE: BRK-A)(NYSE: BRK-B) 2009 purchase of railroad Burlington Northern provides an excellent illustration. As Fool analyst Anand Chokkavelu explains, the deal was a stealth play on rising oil. CEO Warren Buffett laid out the case in a recent shareholder letter:

Last year [Burlington] moved each ton of freight it carried a record 500 miles on a single gallon of diesel fuel. That's three times more fuel-efficient than trucking is, which means our railroad owns an important advantage in operating costs.

Buffett is playing rising oil prices by buying a company that gains a competitive advantage as oil rises. And is there any doubt that higher oil prices are the future? Maybe not today, maybe not tomorrow, but soon -- and for the rest of your life.

The railroad business also benefits by the ongoing growth of trade between the U.S. and China, since it connects key ports on the West coast with America's heartland. That double whammy should create great gains for the company.

In the spirit of Berkshire's Burlington buy, my hidden play on rising energy is Middleby (Nasdaq: MIDD). If you haven't heard of this small cap, let me introduce you. Middleby produces food-processing equipment for the restaurant industry: conveyor ovens, ranges, convection ovens, and more. The company is set to capitalize on three major trends:

1. Rising energy prices
Higher energy costs play right into Middleby's hands, because it leads the industry in energy-efficient equipment. The company offers more than 400 Energy Star-approved products that cook food efficiently without sacrificing quality. For example, Middleby's WOW! oven is the most energy-efficient, fastest-cooking conveyor oven on the market -- 35% faster, yet 30% more efficient, than rival appliances. By cutting energy expenses, and serving more customers in the same amount of time, products such as WOW! help recoup their own purchase costs more quickly.

Its equipment is such a good investment that when Middleby faces higher costs for inputs such as steel, it can pass those expenses on to its customers by raising prices. The company has posted strong -- and even improving -- gross margins over the last three years, indicating its ability to hold the line on pricing. However, Middleby has said that its current round of price increases won't fully offset the latest inflationary pressures it faces.

2. Dining out
In addition to these energy benefits, Middleby also offers a play on the increasing trend of dining out. The recession's hit many restaurants hard in recent years, but the long-term trend remains very much intact. For proof, look no further than successful Chipotle (NYSE: CMG) and Panera Bread (Nasdaq: PNRA), as well as Yum! Brands (NYSE: YUM) and its massive growth opportunity. Then there's Subway, which recently passed McDonald's (NYSE: MCD) to become the world's largest restaurant chain.

These restaurants' swiftly growing store counts bode well for Middleby. Subway alone expects to expand store count by 1,000 to 2,000 per year -- and my local Subway uses Middleby's TurboChef quick-cooking ovens. But that's only part of the opportunity in restaurants.

Middleby is already in a test-run with three large casual-dining chains to increase their return on investment using its products. By offering a complete suite of products to revamp their kitchens, the company is able to decrease labor costs and increase productivity. CEO Selim Bassoul estimates that it's a multimillion-dollar initiative in each restaurant.  The CEO's comments on the test-run thus far: "It is working very well, the test units that we have now, and they are multiunit. Test units have been superb." It's unclear exactly who these large chains are, since Middleby refuses to divulge their names.

3. A mighty distribution network
A huge part of Middleby's appeal lies in its ability to buy smaller players, then leverage its distribution network to gain incremental sales. In just the last year or so, the company has acquired Perfect Fry, Cozzini, and Doyon, and then expanded each purchase's sales through Middleby's network, much like it did a few years back with TurboChef. The company often takes on debt to fund these acquisitions, then repays those obligations using its strong cash flow. CEO Bassoul promises "a strong pipeline of acquisitions."

Foolish takeaway
Middleby most definitely isn't cheap. It trades at a P/E of almost 22 and an EV/EBITDA of 12.8. But the company has managed to grow earnings at nearly 18% per year on average over the last half-decade, winning significant market share in the process. That type of growth suggests a two-bagger in four or five years. But with new initiatives and these huge tailwinds blowing in its favor, it's not hard to imagine Middleby doing much better than that.

Interested in Middleby? Add it your Watchlist, our free, personalized stock-tracking service, and get updates on the stock. Or add Chipotle, McDonald's, Yum! Brands , or Berkshire Hathaway.

Jim Royal, Ph.D., owns shares in Middleby, Berkshire, and McDonald's. Berkshire Hathaway is a Motley Fool Inside Value selection. Chipotle is a Rule Breakers recommendation and a Motley Fool Hidden Gems selection. Berkshire Hathaway and Panera Bread are Stock Advisor picks. McDonald's is an Income Investor pick. The Fool owns shares of Berkshire, Chipotle, ExxonMobil, and Yum! Brands. Try any of our Foolish newsletter services free for 30 days. We Fools may not all hold the same opinions, but we all believe that considering a diverse range of insights makes us better investors. The Motley Fool has a disclosure policy.