The Mexican border, an issue that helped get Donald Trump elected, continues to bedevil his presidency.

One quote from my book "Media Madness," uttered privately before the midterms, has always resonated with me.

Steve Bannon told the president: "Don't think you’re getting away without building a wall. You said it too many times at too many rallies. Nancy Pelosi will get the House. They're going to swear themselves in and [blanking] impeach you."

He was right about Pelosi, though impeachment clearly isn't happening. But Bannon's larger point was that the wall and border security is so crucial to Donald Trump's base that he can't survive unless he does everything in his power to deliver on his promise.

That's why Trump triggered the 35-day government shutdown, that's why he declared a national emergency to get wall funding, that's why he threatened to close the border last week before backing off.

NEW ACTING DHS BOSS HAS LONG RECORD IN BORDER SECURITY

And that's why he forced Kirstjen Nielsen out of her job.

The Homeland Security secretary walked into a meeting with the president Sunday night expecting to stay on the job and walked out unable to get her resignation letter out before he tweeted the news. That's not a voluntary departure. (Yesterday's firing of Secret Service chief Randolph Alles adds fuel to what The New York Times is calling a "purge.")

In the end, she got the worst of both worlds. She will forever be defined as the Cabinet member who presided over the forced separation of migrant children from their families, leading to such devastating worldwide reaction that Trump was forced to abandon the policy. And yet the president did not deem her tough enough on illegal immigration.

READ HOMELAND SECURITY SECRETARY KIRSTJEN NIELSEN'S RESIGNATION LETTER

In fact, based on reports from CNN and NBC, Trump wants to reinstate the family separation approach, and Nielsen's resistance to that may have been the final straw. She had asked for Sunday's sitdown.

"Mr. Trump in recent weeks had asked Ms. Nielsen to close the ports of entry along the border and to stop accepting asylum seekers, which Ms. Nielsen found ineffective and inappropriate," the Times says. "While the 30-minute meeting was cordial, Mr. Trump was determined to ask for her resignation. After the meeting, she submitted it."

Most pundits expected Nielsen to be dumped after the midterms, especially after the departure of her mentor, chief of staff John Kelly, who previously ran Homeland Security and pushed her for the post. But then her position seemed to stabilize.

In a possible harbinger, Lou Dobbs, the Fox Business host who speaks privately with Trump, called for Nielsen's firing on his show nearly two weeks ago.

More from the Times: "The president called Ms. Nielsen at home early in the mornings to demand that she take action to stop migrants from entering the country, including doing things that were clearly illegal, such as blocking all migrants from seeking asylum. She repeatedly noted the limitations imposed on her department by federal laws, court settlements and international obligations.

Those responses only infuriated Mr. Trump further."

Plus: "Multiple White House officials said she had grown deeply paranoid in recent months, after numerous stories about her job being on the line."

It was a bit sad watching Nielsen briefly talk to reporters staked out at her Alexandria home yesterday, thanking the president, offering no hint of their disagreements and taking no questions.

But the press had little sympathy for Nielsen. A Times editorial said she "enforced cruelty at the border."

CNN's Jeff Toobin said Nielsen will be remembered as "the woman who put children in cages."

The Daily Beast's Michael Tomasky: "Kirstjen Nielsen Was Heartless, But Not Heartless Enough for Trump."

But if she is forever defined by the 2018 breakup of families, Nielsen was not an ardent advocate. She "hesitated for weeks about whether to sign a memo ordering the routine separation of migrant children from their families so that the parents could be detained," the Times says. Yet it was she who got hammered at Hill hearings when she had to defend the policy.

Trump will name Customs and Border Protection chief Kevin McAleenan, said to be more of a hard-liner, as her acting successor.

CLICK HERE TO GET THE FOX NEWS APP

The stakes for the president are laid out in a Washington Post piece that also includes his on again, off again assault on ObamaCare:

"Trump's dark warnings pose a central conundrum for his reelection effort: Can he win the White House a second time by railing against the very problems he promised to fix?"

That hearkens back to Bannon's warning to Trump about the border and the wall as the key to 2020 — and explains why Kirstjen Nielsen is about to become a private citizen.