WASHINGTON ― With the specter of Donald Trump’s administration looming, the Supreme Court on Wednesday appeared deeply torn over whether non-citizens who are detained for prolonged periods of time have a right to timely bail hearings that may secure their release.

The president-elect’s name and his proposed policies to round up and deport and his proposed policies to round up and deport millions were not brought up directly. But if the high court accepts the Obama administration’s argument that neither the Constitution nor current statutes guarantee this kind of relief to a wide class of foreign-born detainees, the stance is sure to govern how Trump handles immigration policy. Trump has bashed President Barack Obama for releasing immigrants from detention while they await their deportations.

Justice Elena Kagan, who forcefully challenged the government’s stance in the case, known as Jennings v. Rodriguez, set the tone for how the court might choose to rule in the case.

“You can’t just lock people up without any finding of dangerousness, without any finding of flight risk, for an indefinite period of time, and not run into due process,” said Kagan, referring to the constitutional provision that forbids officials from depriving anyone, including non-citizens, of their liberty.

There are “constitutional bounds” to keeping people in detention for more than six months without a chance to see a judge, she noted.

“Don’t you think due process would require some periodic review to ensure that these people are properly being held?” asked Justice Sonia Sotomayor, observing that many of those who are caught up in immigration detention for long stretches have lived in the United States “for decades.”

“What makes it unconstitutional in my mind is the unreasonable delay of detention,” said Sotomayor.

Alejandro Rodriguez, the lead plaintiff in the class-action case, is a lawful permanent resident of the U.S. who has lived here since he was an infant. He was detained for more than three years without a substantive hearing, as the government sought his deportation based on two minor offenses ― misdemeanor drug possession when he was 24 and joyriding when he was 19.

He challenged his detention and was eventually released, but the proceedings dragged on for seven years before an immigration judge canceled Rodriguez’s deportation and allowed him to remain in the country. But plenty of others who aren’t so lucky are still languishing in detention ― including undocumented immigrants, asylum-seekers and people, like Rodriguez, who are legally in the country but subject to removal.

The Supreme Court’s task is to determine whether the complex web of immigration statutes that apply to these different groups of non-citizens affords them an opportunity to see a judge and vouch for their release ― or else whether the Constitution may grant them that right.

The government is currently holding more than 40,000 people per day, and aiming to add capacity for 5,000 more who are going through removal proceedings or awaiting deportation. For many immigrants, the proceedings take years, particularly given the lengthy backlogs in immigration courts, where more than 520,000 cases are pending.

And although Immigration and Customs Enforcement officials have the power to voluntarily release some immigrants, the agency is “essentially the jailer, said Ahilan Arulanantham of the ACLU of Southern California, who argued the case for Rodriguez and the class, which includes thousands of people. Immigrants should get a chance to go to a neutral party like an immigration judge as well, he said.

“This is a class of mostly unrepresented people,” Arulanantham said, stressing the practical barriers non-citizens would face if their only recourse was to litigate their release on their own. “Everybody in the class, in our view, is entitled to an inquiry” by a judge, he said.

Many of the members of the class ended up winning their cases, raising questions about whether their long-term detention was necessary in the first place. All members were detained at least 180 days during their pending deportation proceedings, and they spent an average of 404 days in detention. Nearly all of those initially detained at the border sought asylum and two-thirds were granted it, according to a brief supporting the ACLU’s position. Those who sought relief from deportation won their cases at a rate five times higher than the detained immigrant population generally.

When Justice Samuel Alito questioned whether such a broad class of immigrants should have been allowed at all, Ian Gershengorn, representing the Obama administration, complained that the move was improper because affected immigrants get a chance to appeal their removal individually.

“That one-size-fits-all approach is not the right way to do it,” Gershengorn said, suggesting that the law requires immigrants to challenge their detention individually in federal court. This drew a rejoinder from Kagan.

“Wouldn’t it be better to set some guideposts that everybody in the country would know to follow rather than having one suit pop up here and one suit pop up here and another in another place and everybody would be treated differently?” Kagan asked. “That does not seem like a good immigration system.”

If a definitive guidepost exists at all, a sweeping constitutional ruling in favor of immigrants might provide it. But the last time the Supreme Court handled an immigration case with constitutional implications, it deadlocked 4-to-4 ― which is also a possibility this time around.