The U.S. flag flies in front of the Supreme Court building at sunset in Washington, D.C. (Andrew Harrer/Bloomberg)

The justices of the Supreme Court on Wednesday diagrammed sentences, debated modified nouns and generally approached from every conceivable angle the federal law that resulted in Moones Mellouli being deported after he pleaded guilty to a drug paraphernalia charge.

But they continually returned to this: the “paraphernalia” was a sock, and the drug Mellouli had placed in it was four tablets of Adderall, an amphetamine that Justice Elena Kagan said one would be likely to find if you “just randomly pick” someone walking across a college campus.

“If it’s not such a big deal that the state is willing to let him cop a plea to drug paraphernalia,” asked Chief Justice John G. Roberts Jr., “why should that be the basis for deportation under federal law?”

But like all matters before the Supreme Court, the subject is more complicated than that. Congress has made it clear that noncitizens convicted of some crimes can be deported. But many of those convictions are under state laws, which can differ from federal laws. And those differences are particularly significant when it comes to drugs.

So Congress said a noncitizen becomes eligible for removal when convicted of violating “any law or regulation of a state, the United States or a foreign country relating to a controlled substance” as defined in federal law.

Since Mellouli pleaded guilty to a drug paraphernalia charge, rather than possession of a controlled substance, the question is whether his conviction is related to a controlled substance.

“That methodology has led to tens of thousands of drug deportations each year, but not for someone convicted of possessing a sock,” said Mellouli’s lawyer, Jon Laramore.

Mellouli, from Tunisia, entered the United States on a student visa in 2004 and became a lawful permanent resident in 2011. While here, he earned two master’s degrees and taught at the University of Missouri.

He was arrested in Kansas in 2010 for driving under the influence and having a suspended license. At the detention facility, authorities discovered the four tablets in a sock he was wearing.

Mellouli pleaded guilty to driving under the influence and also to using or possessing drug paraphernalia, which under Kansas law means anything that can be used to “store, contain, conceal, inject, ingest, inhale or otherwise introduce a controlled substance into the human body.”

He received probation and a suspended jail term.

But Immigration and Customs Enforcement officers arrested him in 2012. He was deported when the Board of Immigration Appeals and then the U.S. Court of Appeals for the 8th Circuit turned down his pleas to remain in the country. If his case before the Supreme Court is successful, he’d like to return.

Laramore’s argument did not start out well. Justice Samuel A. Alito Jr. told him to pretend he was back in high school: What noun is “relating to a controlled substance” modifying?

Laramore acknowledged that the answer was probably “law.”

“If it modifies ‘law,’ then I think you’ve lost the case,” Alito replied.

But other justices weren’t so sure.

“One of the strange things about this case is you have a disjunction,” said Justice Ruth Bader Ginsburg. “ A sock doesn’t count as drug paraphernalia under the federal law, but it does under the state law; it means any container.”

Moreover, Kansas’s law concerning drug paraphernalia covers drugs that are not on the federal schedule.

But Assistant Solicitor General Rachel P. Kovner said Congress intended for immigration officials to have broad leeway to remove noncitizens who violate drug laws, state or federal.

“State drug laws that cover hundreds of federally controlled substances, in addition to some additional drugs, are laws that relate to federally controlled substances,” she said.

She added: “He wasn’t exactly convicted of having a sock. He was convicted of using an innocent item as a tool for the storage of drugs, and that’s true of every drug paraphernalia conviction.”

By the end of the argument, even Alito was wondering whether Mellouli’s charge was really a proper reading of the broad Kansas law. Under such a definition, Alito said, a baggie, a pocket or a glove compartment could be considered paraphernalia if the same drugs were temporarily stored in each.

Kovner said that illustrated why immigration officials needed leeway, because otherwise they might have trouble deporting someone convicted on a paraphernalia charge even if cocaine were stored there.

Responded Kagan: “If he had cocaine in his sock, he would probably be convicted of possession of cocaine.”

The case is Mellouli v. Holder.