“This is un-American!” has been one of the more common reactions to the news about the Trump administration’s decision to enthusiastically tear apart immigrant families and throw toddlers in cages – or, as Fox News’s Steve Doocy delicately put it, not cages but “warehouses with walls built out of chain-link fences”. “This is not who we are!” cry my fellow American liberals. But when does what a country does become what a country is?

The stories now coming out of the United States are so devastating they can only be described as a national moral stain: five-year-olds being led away by officers who say they are giving them a bath, only for their parents to then be told they won’t be seeing them again; mothers being deported and forced to leave children behind with no way of contacting them; hundreds of terrified children locked within chain-link fence walls, aka cages, while an official jokingly describes their cries as “an orchestra”.

President Trump’s team is currently reacting to these stories by alternately denying their veracity and defending their effectiveness, and in the case of Kirstjen Nielsen, US secretary of homeland security, doing both simultaneously. The rest of us want to throw up on our shoes and cry. But as horrific as these stories are, they are only happening because casual racism against immigrants has long been part of America’s identity. I am currently writing a book about immigration in America in the early 20th century, and you don’t have to look too hard to find a tradition of foreigner-bashing. The Emergency Immigration Act of 1921 was written to prevent the country being polluted by “abnormally twisted” Jews, who were deemed “filthy, un-American and dangerous in their habits”. It passed overwhelmingly, but according to those who wrote it, it did not go far enough. So in 1924 the Johnson-Reed Act was proposed, which effectively banned all Asians from entering the country. It was intended, as congressman Albert Johnson put it, to “keep American stock up to the highest standard – that is, people who were born here”. It too passed in the House and the Senate without a glitch.

America is built on racism, but it is also built on immigration, and these are not so much two sides of one coin but a snake eating its own tail. Immigrants have been othered so effectively by politicians that people who talk proudly about seeing their great-grandparents’ names in the books at Ellis Island, or boast about being able to trace their family tree to the Mayflower, will tut anxiously about illegal immigration, as though the Mayflower travellers all had visas. Few who talk about immigration talk about why these people are immigrating in the first place. What are they fleeing from? Who cares?

My grandmother fled the Nazis. It’s the only reason I was born in America – or at all, for that matter. She had to gain entry by agreeing to marry a man she didn’t know, who lived in Long Island. She couldn’t get her mother, siblings or cousins in, however, and as a result many of them were murdered.

Analogies with Nazism can be unhelpful, but it is impossible for those of us who are descendants of Holocaust survivors to listen to those tapes of children crying for their parents and not think about the Jewish children in our family who were forcibly separated from their parents. When asked about the comparisons between his detention centres for children and concentration camps, the attorney general, Jeff Sessions, described them as “an exaggeration” – the Nazis “were keeping the Jews from leaving the country”, he bleated. Attention, all politicians: if the best you can say for your policy is you are not literally killing people like the Nazis did, you are on the wrong side.

We are shocked, but should we be surprised? Donald Trump talked repeatedly during the campaign about ending Obama’s so-called catch-and-release policy, which effectively made an exception for illegal immigrants with children so as not to have to split up families. Trump promised to deport “the bad hombres”. Many laughed this off, insisting this was just a figure of speech, but there was one person who took his words seriously. Hillary Clinton said in one debate, “I don’t want to rip families apart. I don’t want to see the deportation force that Donald has talked about.” Tell me again, Bernie bros and third-party voters, about how there’s no significant difference between Trump and Clinton.

With the exception of the few surviving descendants of Native Americans, every single person in America is there because someone in their family immigrated. And while most of us have got used to a certain amount of hypocrisy from politicians on this subject, the images of lone toddlers, knee high to the immigration officials taking their parents away, have exposed the bottomless cruelty of the right. They will rage in defence of the rights of “the unborn child”, but throwing kids in cages is apparently fine. This administration has so successfully demonised non-white immigrants (“They’re bringing drugs, they’re bringing crime, they’re rapists,” according to Trump during the campaign), that they are not seen as families but as animals from “shithole countries”, to use another of the president’s terms. This is how Republicans like Ivanka Trump and Paul Ryan can tweet cheerful photos of themselves with their children during this saga: they might be, respectively, descendants of eastern European and Irish immigrants, but in no way do they relate their families to the ones being ripped apart.

America is both an ideal and a reality, and sometimes the two gel and sometimes they really don’t. Trump ran a racist campaign exploiting decades of demonisation of immigrants, and a lot of people liked it, and this is the result. The policy, with its targeted cruelty against children, has Trump written all over it. But the path that led us here is, alas, all too American.

• Hadley Freeman is a Guardian columnist