Updated

President Barack Obama was veritably shell-shocked in the wake of Donald Trump's election victory in 2016, and even asked aides “What if we were wrong?” as he struggled to come to terms with Hillary Clinton's defeat, former adviser Ben Rhodes writes in a new memoir coming out in June.

The book, titled "The World As It Is," highlights efforts by Obama's brain trust to reassure him that he would have won re-election if he were allowed to run for a third term.

But Obama remained alternately optimistic and dejected, according to Rhodes, who has been feted as an aspiring novelist-turned national security wunderkind.

“Sometimes I wonder whether I was 10 or 20 years too early,” Obama told aides, according to the memoir. “Maybe we pushed too far. ... Maybe people just want to fall back into their tribe.”

“There are more stars in the sky than grains of sand on the earth," the book quotes Obama saying in a message to Rhodes the day after the election.

"Maybe this is what people want."

— Former President Barack Obama, trying to understand Donald Trump's election win

Days later, Obama reportedly came back down to Earth, saying: “Maybe this is what people want. I’ve got the economy set up well for him. No facts. No consequences. They can just have a cartoon.”

Rhodes was promoted from presidential speechwriter to deputy national security adviser under Obama. He held that post during the raid that killed Usama bin Laden, as well as the U.S. intervention in Libya and the signing of the Iran nuclear deal.

The possibility that Trump could unravel that legacy apparently weighed on Obama, Rhodes writes.

FMR OBAMA OFFICIALS FORM ANTI-TRUMP THINK TANK

“I feel like Michael Corleone," Obama reportedly said, referencing "The Godfather" character as he prepared to hand over the White House to Trump. "I almost got out.”

According to Rhodes, he and Obama were not aware that the FBI had begun an investigation into the Trump campaign's dealings with Russia until after the election.

The book also touches on some foreign-policy melodrama as Obama made his exit from the world stage, amid a shifting geopolitical climate that included Brexit and rising disenchantment with globalism.

Chancellor Angela Merkel of Germany had a "single tear in her eye" when she and Obama parted for the last time, and Obama noted that "she's all alone" to defend his liberal principles, according to Rhodes.

BEN RHODES JOKES ABOUT GOP LEADERS' 'OBITS'

In footage from an HBO documentary recording on election night in 2016, Rhodes himself was seen sitting alone outside on a bench, haltingly repeating that the situation was difficult to "process."

But in his memoir, Rhodes says he should have predicted the result.

“I couldn’t shake the feeling that I should have seen it coming,” he writes. “Because when you distilled it, stripped out the racism and misogyny, we’d run against Hillary eight years ago with the same message Trump had used: She’s part of a corrupt establishment that can’t be trusted to bring change.”