WASHINGTON (JTA) — Justice Elana Kagan asked the lawyer defending the president’s travel ban to imagine the same ban if it applied to Israelis.

In her hypothetical challenge during oral arguments on President Donald Trump’s ban on travel from several Muslim majority countries, Kagan asked if a similar ban on Israelis by an anti-Semitic president would be constitutional.

What if “a vehement anti-Semite (who) says all kinds of denigrating comments about Jews” during his campaign is elected president and then issues a travel ban on Israelis, Kagan, who is Jewish, asked Noel Francisco, the solicitor general who was defending the ban, in hearings Wednesday.

Francisco said it could be legal. “If his Cabinet were to actually come to him and say, ‘Mr. President, there is honestly a national security risk here and you have to act,’ I think then that the president would be allowed to follow that advice even if in his private heart of hearts he also harbored animus,” he said.

Opponents of the ban say it is discriminatory because of comments Trump made as a candidate and then as president indicating he was targeting the countries because of what he perceieved as a broader Muslim threat.

The Trump administration contends that the ban is too narrow to be considered discriminatory. There have been several iterations of the ban; currently, Muslim majority countries on the list include Syria, Libya, Iran, Yemen, and Somalia.

A number of Jewish groups, including HIAS, the lead immigration advocacy group in the Jewish community, the Anti-Defamation League and the National Council of Jewish Women, have joined briefs challenging the ban.

The Zionist Organization of America has filed an amicus brief in support of the ban.

Kagan elicited laughter when she described her hypothetical. “This is an out-of-the-box kind of president in my hypothetical,” she said.