Housing and Urban Development Secretary Ben Carson has taken a lot of heat over the past 24 hours for calling slaves "immigrants," but it turns out former President Barack Obama drew a similar comparison in 2015.

"That’s what America is about, a land of dreams and opportunity," Carson said during his inaugural address to the HUD staff. "There were other immigrants who came here in the bottom of slave ships, worked even longer, even harder for less."

"But they too had a dream that one day their sons, daughters, grandsons, granddaughters, great-grandsons, great-granddaughters, might pursue prosperity and happiness in this land," he added.

Ben Carson just referred to *slaves* as "immigrants" "There were other immigrants who came here in the bottom of slave ships..." pic.twitter.com/WkFrm3dYCB — Steve Kopack (@SteveKopack) March 6, 2017

The National Association for the Advancement of Colored People was bewildered by the comparison, actor Samuel L. Jackson slammed Carson for the statement and MoveOn's national spokeswoman said the HUD secretary "needs to revisit" the National Museum of African-American History and Culture.

(Content warning: The language used in the below tweets might be offensive to some readers.)

But, as Breitbart's White House correspondent Charlie Spiering pointed out, Carson's comments are not without precedent. In fact, Obama equated slaves and immigrants during a naturalization ceremony in December 2015.

The former president, a Democrat, made the comments when he was explaining that coming to the U.S. isn't necessarily "easy for new immigrants."

"Certainly," Obama explained, "it wasn't easy for those of African heritage who had not come here voluntarily and yet in their own way were immigrants themselves. There was discrimination and hardship and poverty."

Former President Barack Obama speaks during a naturalization ceremony at the National Archives in Washington, D.C., Dec. 15, 2015, on the 224th Anniversary of the Bill of Rights. Obama compared immigrants and slaves during his address. (JIM WATSON/AFP/Getty Images)

"But, like you, they no doubt found inspiration in all those who had come before them," he continued. "And they were able to muster faith that, here in America, they might build a better life and give their children something more."

And it appears this comparison was a common thread in Obama's speeches during naturalization ceremonies. In July 2012, he said: "We are a nation of immigrants."

"Unless you are one of the first Americans, a Native American, we are all descended from folks who came from someplace else — whether they arrived on the Mayflower or on a slave ship, whether they came through Ellis Island or crossed the Rio Grande," Obama said.