This is the fifth and final article in a series on Bank of America's legal problems since the financial crisis. Links to the rest of the series are at the bottom of this article. 

If there is one question that shareholders in Bank of America (BAC 3.15%) obsesses over, it's this: When will the tens of billions of dollars in losses from its acquisition of Countrywide Financial finally end?

By my count, B of A has paid more than $35 billion to date, excluding legal fees, to resolve claims related to Countrywide's origination of faulty mortgages in the lead-up to the financial crisis. And by my count, it still has between $15 billion and $25 billion beyond stated reserves left to go.

Are greener pastures ahead?
Given the financial weight of these problems, it's no surprise that executives of the nation's second largest bank by assets have spent much of the past five years near-maniacally focused on them. They come up in every quarterly conference call, are given valuable real estate in earnings releases and presentations, and are ubiquitous throughout media interviews with the bank's CEO, Brian Moynihan. The lawyer-cum-banking executive recently compared the struggle to climbing a mountain with a 250-pound backpack.

While the bank's focus has been fruitful, it's nevertheless come at a price. B of A has paid more than $13 billion to resolve complaints about its servicing of mortgages, roughly $11 billion to dispose of claims brought by (or for) Fannie Mae and Freddie Mac, and more than $10 billion to settle disputes with institutional investors in Countrywide's mortgage-backed securities.

Taken together, the related charge-offs have decimated the bank's earnings for half a decade.You can see this breakdown in the following infographic -- the green houses represent settled claims, and the red houses show estimates of liability remaining.

Sources: Bank of America's quarterly and annual reports, media reports, and court documents.

For the first time since the crisis began, however, there's reason for shareholders to be optimistic. In B of A's third-quarter earnings release, its CFO Bruce Thompson revealed that the executive team has now "turned our attention to driving core earnings." And while words are all well and good, we've also seen actions that show the bank moving in this direction. 

At the end of last year, and after multiple quarters of contraction, Moynihan confirmed that B of A has set its sights on expanding mortgage originations in an attempt to compete with the likes of Wells Fargo (NYSE: WFC), the nation's largest mortgage originator. One month later, Moynihan sent a letter to each of the bank's 270,000 employees about the need to overhaul its reputation for abysmal customer service. And most recently, B of A announced a new marketing campaign designed to repair its tarnished image in the eyes of consumers. "It just boils down to being better than we are today," Moynihan said.

Whether or not it's too early to celebrate, of course, remains to be seen. Pushed by Bloomberg's Erik Shatzker to compare the bank's progress on the legal front to the innings of a baseball game, Moynihan replied: "I never like analogies like that because you never know if it goes into extra innings." By this, he's likely referring to three separate but ongoing legal battles.

The first concerns a series of particularly contentious lawsuits brought by bond insurers like MBIA (MBI 1.16%) which are hurtling toward trial in a New York state court. The second involves a judicial proceeding in the very same court over the legitimacy of an $8.5 billion settlement between B of A, the Bank of New York Mellon (BNY 0.19%), and 22 institutional investors, including bond giants Black Rock (BLK 0.25%) and Pimco. And the third revolves around a constellation of securities fraud actions asserted by parties like AIG (AIG 1.64%) against B of A in a federal court in California. As I've noted before, the manner in which these battles play out will dictate not only when B of A fully emerges from the proverbial fog of war, but even if it completely emerges at all.

The Foolish bottom line
Over the past few months, I've joined a growing number of other bank analysts that have turned bullish on B of A. In the middle of last year, my colleague Anand Chokkavelu predicted that its shares could "double or triple over the next five years" -- something that they since went on to do. This past December, Meredith Whitney said she had "not seen an opportunity like [B of A] in four or five years." And at the end of last month, Tom Brown, the founder and head of hedge fund Second Curve Capital, predicted that B of A's stock will "reach the low $20s over the next 18-24 months."

After completing an extensive review of B of A's outstanding legal liability, I remain committed to this position. At the same time, it's also underscored the heightened degree of risk in its stock. Make no mistake about it, while there's significant upside potential here, it will still be years before both the stock and its dividend fully and finally recover. But for those with the stomach and patience to ride out the storm, I believe you'll be justly rewarded.

Continue reading this series: