(Brian Snyder/Reuters)

Among the string of Donald Trump-related nightmares that keeps the Republican establishment up at night is the idea that he might at some point give up on winning the party's nomination and instead run as an independent. Within the first 30 seconds of the first primary debate, Trump reinforced that concern. Asked by Fox News's Bret Baier who would not pledge to support the eventual nominee, Trump rather sheepishly raised his hand.

It's an establishment nightmare precisely because of Trump's willingness to toy with the idea -- and what would happen if he went through with it. In repeated polls of a three-way race, Trump draws much more heavily from the Republican pool than the Democratic one, essentially handing Democrats the White House.

So the establishment is trying to keep that from happening. The Republican Party in Virginia and North Carolina is considering adding an extra qualification for those wishing to appear on their state's primary ballots: A commitment to support the eventual Republican nominee. Which may prompt the casual observer to ask, "Can they do that?"

The answer is yes. Adding external, seemingly tangential stipulations to primary ballots is both perfectly within the rights of state parties -- and something with a long history. Richard Winger, editor of the three-decade-old journal Ballot Access News, spoke with The Post by phone to walk through how it works.

"Ever since 1972, the Supreme Court has upheld the ability of political parties to control their own nomination process," Winger explained. That independence leverages the First Amendment's freedom of association clause. "Parties are private organizations," Winger said. "They have the right not to be merged with the government. They are associations of people that come together and work together for common political goals, and so essentially they're private." And therefore can control their own membership -- and candidates.

That control takes various forms. "In Hawaii, parties have the right to expel members," Winger said. "The state elections department in Hawaii heard from the Green Party, 'Please take these peoples' names off our primary ballots because they're pro-life and that contradicts our platform.' The candidates sued, but they lost. The party had a right to do that." In 2004, the Alabama Republican Party booted a candidate from its ballot after she endorsed the Constitution Party on a radio talk show she hosted. The candidate, Kelly McGinley, sued -- but lost at the state supreme court.

There are limits to how a party can police itself. Once upon a time, the Democratic Party in Texas and South Carolina excluded black members. Texas's law, enacted in 1923, was struck down by the Supreme Court in Nixon v. Herndon four years later.

In 2008, the Texas Democratic Party introduced another new rule: Candidates had to pledge to support the eventual nominee. Former Ohio representative Dennis Kucinich declined to do so, and sued. "He lost in every round," Winger says. "He lost in U.S. District Court, he lost in the Fifth Circuit, and the U.S. Supreme Court wouldn't hear it." That case establishes pretty clearly that Virginia and North Carolina can apply the limit they're considering.

Ultimately, though, the loyalty oath depends on the good word of the candidate. If a candidate -- call him Ronald Bump -- were to pledge to support the Republican nominee but then decided to run as an independent, there's nothing that could be done to prevent him from doing so. The repercussions would be solely in the judgment of the voters. Which, for our hypothetical Bump candidate, might not be a significantly limiting factor.

Winger said he'd gotten a call from a reporter in another state that was thinking about implementing a similar rule. He was skeptical about it, but not because it wouldn't be very effective.

"I didn't think they would do it, because I thought it would make him mad," Winger said about Trump. "You don't want to make him mad! It might be unwise for them to do that."