Nancy Pelosi has never lost the vote in a leadership fight, or on the floor of the House, and she intends to reclaim the speaker’s gavel should the Democrats win back the House.

Had Hillary Clinton won the 2016 election, Pelosi planned to give up her San Francisco seat and move on, confident the Republic was in safe hands. Instead, she stayed to fight the good fight, and her future will be determined by what happens in November. If the Democrats fail to regain the House majority after a year of anticipation, those dashed hopes would surely end Pelosi’s storied career.

But with most forecasters predicting a Democratic win in the House, the leadership picture gets complicated. Will Pelosi dig in her high heels for another tour of duty as speaker, and will newly empowered Democrats drawn from the Resistance remain loyal to a leader that some of them ran on opposing?

“No one thinks Nancy is about to give up without a fight,” says David Wasserman, who tracks House races for the non-partisan Cook Political Report. “The question is whether there are enough Democrats to get her to 218. If they take back the House by 5, I can name you 5 Democrats who won’t vote for her. If they take it back by 25, there may be enough wrangling room for her to get the 218.”

If Democrats win, they will have elected an historic number of women to the House. “I don’t think anyone is going to turn around and say let’s get rid of the only woman who’s ever served as leader of a political party in Congress, and replace her with an older man. I just don’t buy it,” says a House leadership aide, who asked for anonymity.

The older man is House Minority Whip Steny Hoyer, a Maryland Democrat who has been the second in command to Pelosi for the last 16 years. Hoyer is popular with his colleagues, and facilitating his lifelong dream of becoming speaker would be a Hollywood musical ending, but in the 21st century, how do Democrats, if they win the majority championing change, go from Pelosi to a 79-year-old white male Democrat to lead a majority minority caucus?

“That’s not the trajectory of the party or the country,” says John Lawrence, Pelosi’s former chief of staff and founder of the blog, DOMEocracy. Lawrence recalled to The Daily Beast his discussions with Pelosi in past leadership fights. In 2016, almost a third of House Democrats voted against Pelosi in a secret ballot.

Pelosi is fine with Democrats doing what they must do to win in November. “Her focus is winning the majority, and the rest will take care of itself,” says Lawrence. “She always says, ‘If you don’t have 218 votes, we’re just having a conversation.”

The leadership vote is a two-step process with a secret ballot first in the caucus, followed by a public vote on the floor of the House. There is a lot of loyalty to Pelosi in the caucus. She’s been assiduous in placing women and minorities in key posts, and her fundraising prowess is unparalleled. Democrats owe her. She’s had their backs for 16 years, since becoming the first woman to lead one of the parties in 2002, and later as speaker for four years after Democrats reclaimed the House in 2007.

Whether Democrats will continue to honor that debt to Pelosi after the midterms depends on the outcome. “Democrats who campaigned on opposing Pelosi could find themselves in a dilemma,” says Lawrence. “If you wanted to avoid that dilemma, you can say I voted against her in the caucus, which is a secret ballot.”

Then on the floor, when the choice is Pelosi or, say, Republican Kevin McCarthy, it’s a party-line vote. “If you’re new to Congress, and you’re part of the resistance, is your first vote to launch the Democratic Party into chaos? You may have to have your head examined to do that,” says Lawrence.

The focus has been on the Republicans, and their succession fight now that Speaker Ryan has called it quits. But it could be as much of a mess on the Democratic side, says Wasserman. “Democrats are looking for a woman and a new generation and a moderate,” and Pelosi, Hoyer and a third top contender, New York Rep. Joe Crowley, a congenial Irishman from Queens, don’t meet those qualifications.

That has led to speculation that the 56-year-old Crowley, or even Hoyer, might try to launch a ticket with a female colleague. “They badly need to build an alliance with a female aspirant,” says Wasserman. Cheri Bustos, a 56-year-old Democrat who represents a working-class district in Illinois, checks all the boxes and is working hard to mentor candidates, especially women.

There’s even some buzz about drafting Adam Schiff, the ranking Democrat on the House Intelligence Committee, who has impressed his colleagues with his serious bearing on television in the face of repeated taunts from President Trump.

But no one is directly challenging Pelosi. The first move is hers to make, and it will hinge on the outcome of the November elections. Crowley, her most obvious successor, recently introduced Pelosi as the next Speaker at an event in Washington honoring women.

After the November elections, it will come down to what a newly emboldened Democratic caucus decides. “Our focus is on winning,” says Drew Hammill, Pelosi’s longtime spokesman. “But Nancy Pelosi always says her future is up to the members.”