The death of Justice Ginsburg, and the president’s promise to quickly fill her seat, threaten to make an already dangerously polarized political situation worse.

The valuable institution of judicial review could become a casualty. Fortunately, there is a politically feasible way to avert such a disastrous scenario.

Democrats believe that one or more of the sitting Republican-appointed justices are ill-gotten gains, products of what they consider to be the “theft” of the seat left vacant by Justice Scalia’s death in 2016, and the contentious confirmation process for Brett Kavanaugh.

In response, they threaten to “pack” the Court, should they gain control of the presidency and the Senate after the November election (a very plausible prospect).

Republican leaders’ insistence that an open seat had to be left vacant in 2016 in order to let the voters decide who should fill the vacancy, but now insist the vacancy left by Ginsburg’s death should immediately be filled — on the eve of the 2020 election —  has the stench of obvious hypocrisy, and willingness to subordinate even their own self-proclaimed norms to partisan advantage.

In addition, a rushed confirmation in the midst of an election where senators have many other priorities increases the risk that the nominee will not get proper scrutiny, and key flaws might go undetected until it is too late.

The Democrats have their own history of playing “hardball” on judicial nominations. But recent GOP actions represent a further escalation of this longstanding conflict, one exacerbated by Republican willingness to override their own principles whenever convention.

But should the Democrats’ respond with court-packing, they would make a bad situation even worse. Any successful Democratic court-packing plan would be met with retaliation in kind the next time Republicans controlled the White House and Congress simultaneously.

And the same thing would happen in the future, any time either party gets the chance. As Democratic presidential candidate Joe Biden put it last year: “We add three justices. Next time around, we lose control, they add three justices. We begin to lose any credibility the court has at all.”

Over time, the Court will lose all ability to act as an effective check on the party in power, as that party can always resort to further packing to override adverse court decisions.

Those who think that court-packing is preferable to having a court with an ideologically inimical majority would do well to remember that the destruction of judicial review by court packing is a standard tool of authoritarian populists seeking to undermine liberal democracy, recently used in such countries as Hungary, Turkey and Venezuela.

Liberal and conservative justices differ on many issues. But they are often united on such key principles as protecting freedom of opposition speech, constraining invidious discrimination against minorities and limiting breaches of separation of powers, among others.

Conservative judges have helped overturn Trump administration abuses of power on freedom of speech, federal coercion of sanctuary cities,  attempts to repeal DACA and other issues. For their part, liberal Supreme Court justices helped curb the Obama administration on property rights and religious freedom, among other cases.

Too often, judges are not as tough as they should be in reviewing policies favored by “their” side of the political spectrum. But they still play a valuable role in constraining the other branches of government.

Destroying judicial review through court-packing would leave both right and left worse off, exposing their rights to unconstrained abuse whenever their opponents are in power.

Fortunately, there is a way this prospect might yet be avoided. Key GOP senators can agree not to vote on a nominee until after inauguration and key Democrats (enough to block court-packing) can commit to opposing court-packing for a long period of time (perhaps 10 years).

Making this deal work requires the agreement of only four Republican senators, which would be enough to block confirmation before the winner of the election has a chance to choose the new justice.

Two have already expressed opposition to confirming a nominee before then, and two more could potentially do so if they get the reciprocal concession of a guarantee against court-packing.

In that event, they can forestall accusations of betrayal by pointing out that they have secured a deal that guarantees at least a 5-4 conservative majority on the Court for some years to come. By contrast, in the absence of a deal, any conservative majority will remain vulnerable to reversal by court-packing.

On the Democratic side, key moderate senators will have incentives to keep their end of the bargain, because they already dislike court-packing (which is unpopular, and would likely become more so after a deal).

The same goes for Joe Biden, should he become president. He too has expressed opposition to court-packing in the past, and in the aftermath of a deal would have every reason not to spend valuable political capital fighting for it at a time when he would have many other fish to fry.

Our highly polarized political system makes beneficial compromise very difficult. But this deal can give key senators a rare opportunity to do well by doing good.