Republicans won by losing the right races this week. And America is better because of it.

A pair of ancient philosophers wrote: "You can't always get what you want. But if you try sometime, you'll find, you get what you need."

The Republican Party got exactly what it needed in the midterm elections.

More important, so did the rest of America.

It appears that the Republicans will end up with control of the U.S. House for the next two years, although not with the margin they expected. Republicans may yet gain a Senate majority, even if it is Herschel Walker carrying the ball in the Georgia runoff.

But there was no red wave in this election, and party leaders already should be making plans to engage in a sober analysis of why so many candidates failed to meet expectations.

The art of the concession speech: How to lose your election graciously

Republicans need a leadership purge

That analysis ought to include more than a few days of deep soul-searching about what the party has tolerated and promoted in recent years. Now is a great opportunity to purge the grifters, liars, bigots and whack-a-doodles (that's the technical term) who have not only infiltrated but also risen to power in the party since 2016.

The purge needs to begin with one Donald J. Trump, who as its tacit leader has guided the party to either defeat or an embarrassingly soft win for the past three national elections.

Opinion alerts: Get columns from your favorite columnists + expert analysis on top issues, delivered straight to your device through the USA TODAY app. Don't have the app? Download it for free from your app store.

It also should put an end to the dangerous idea that Republicans can pluck any second-rate celebrity out of the green room and turn them into an Election Day winner. Yes, I'm talking about TV star Dr. Mehmet Oz in Pennsylvania, local TV anchor Kari Lake in Arizona and long-ago football standout Herschel Walker (who may yet win a Senate seat in Georgia).

But Trump ... No, not but Trump.

Yes, the reality TV star won Michigan, Pennsylvania and Wisconsin – and therefore the White House – six years ago. He's been a disaster, however, for the party ever since, and not just on Election Day.

Come on, Republicans: Our midterm losses are the final straw. Dump Trump now.

More important, again, he's been a disaster for America, pulling us further apart and exploiting our divisions for the benefit of his insatiable ego.

If not Trump and Gang to lead Republicans, then who? A lot of solid, smart Republicans did well in this election.

Starting, of course, with Florida Gov. Ron DeSantis. But DeSantis wasn't the only Republican incumbent who sailed to an easy win in gubernatorial races.

DeSantis vs. Trump: We just got through the midterms, but the rivalry for 2024 has already begun

Call on GOP governors to lead

Republicans have a strong class of governors leading a majority of the 50 states. That leadership group is ripe for promotion.

In the Senate, Marco Rubio from Florida, Tim Scott from South Carolina and Todd Young from Indiana cruised to victory. Republicans could build a solid leadership team in the Senate with that trio at its core. And Mitch McConnell, who has tried to push back against Trumpism, may still emerge from this election as Senate majority leader.

Republicans also added much-needed diversity to Congress. In Oklahoma, Markwayne Mullin became the first Native American elected to the Senate in almost two decades. In Alabama, Katie Britt is the first woman elected to the Senate and, at age 40, she'll be one of the youngest members of the upper chamber, where the median age is nearly 65.

Republican Katie Britt wins the U.S. Senate race in Alabama on Nov. 8, 2022, becoming the first woman elected to the body from the state.
Republican Katie Britt wins the U.S. Senate race in Alabama on Nov. 8, 2022, becoming the first woman elected to the body from the state.

In the House, California Republican Kevin McCarthy could win three times: his own reelection, the House speaker job and the excising of Colorado headache Lauren Boebert from the GOP caucus (her race appears headed to a recount).

In horticulture, pruning helps to keep trees and vines healthy by cutting off dead and unhealthy branches. It also triggers fresh growth and, in fruit trees and grape vines, a more abundant harvest in the future.

Voters turned the pruning shears on the Republican Party in the midterms. It definitely wasn't what the GOP wanted – dreams of a red tsunami were dashed. But it was necessary.

Future of the GOP: Republicans must move past Trump for sake of the party's future – and the nation's

The hubris of so many on the right was shown up, and the dishonesty and recklessness of the party's Trump wing were rebuked again. Left standing were traditional conservatives who can now leverage the disappointments of Election Day 2022 to take back control of the party.

As I've noted in a previous column, in a nation with only two major political parties, Americans need both of them to be healthy. The results of this election, although a short-term setback for the GOP,  can lead in the long term to a stronger, more stable Republican Party.

And that's what all of America needs.

Tim Swarens is deputy opinion editor for USA TODAY. 

More from Tim Swarens:

Federal Reserve's rate hikes hurt Americans. But it's our only hope against inflation.

Is John Fetterman fit for office? His health challenges shouldn't be off-limits.

Republicans must move past Trump for sake of the party's future – and the nation's

You can read diverse opinions from our Board of Contributors and other writers on the Opinion front page, on Twitter @usatodayopinion and in our daily Opinion newsletter. To respond to a column, submit a comment to letters@usatoday.com.

This article originally appeared on USA TODAY: Republican wave didn't happen this election. That's good for the GOP.