A prosecutor, a defense attorney and a judge worked together Friday to fashion a sentence that they hope will help a man who has struggled with a drug addiction — which led to the death of his stepbrother — get a second chance.

Stephen. A Piper could’ve been sentenced to decades in prison.

But instead, Piper could be paroled as early as July 1 to inpatient drug treatment. His sentence came with a warning from Judge Christopher Feliciani, who said he looked past expletives Piper used in court to express how the 2021 accidental drug overdose death of 33-year Gerald Lentz Jr. has affected him.

“The potential sentence here goes up to 40 years,” Feliciani said.

Piper, 37, of Latrobe, was sentenced to one year less a day to two years less a day in the Westmoreland County Prison in a drug delivery resulting in death case in which he is accused of providing a fatal dose of drugs to Lentz. He will be eligible for parole July 1 and will have to go directly to inpatient treatment followed by a halfway house.

After he’s done at the halfway house, Piper will start a five-year probation term and three years of house arrest. If he complies with the conditions, house arrest may be lifted after 18 months, Feliciani ordered.

Piper testified against co-defendant Andrey Young, 44, during Young’s April drug delivery resulting in death trial involving Lentz, of Unity, who died March 1, 2021. Young was acquitted of providing the fentanyl-laced heroin that caused the fatal overdose, but was convicted of possession with intent to deliver and drug and paraphernalia possession charges.

He was sentenced to three and a half to seven years in a state prison. Piper pleaded guilty in December.

Despite Young’s acquittal on the most serious count, Assistant District Attorney Adam Barr said Friday that Piper’s cooperation should still be considered as part of his sentence. But so should his need for drug rehabilitation, Barr said.

“I don’t want to see Mr. Piper locked up for a lengthy period of time, but at the same time, I don’t want to see him fall to the same vices,” he said.

Defense attorney Michael Garofalo said Piper requested an extended period of house arrest to help him stay sober. Piper told Feliciani he thinks he needs grief counseling, too.

“I lost my brother and it has me messed up in my head over it,” he said.

In addition to the drug delivery resulting in death case, Piper was sentenced in six other cases involving charges that ranged from retail theft to drug possession. He was either paroled or the sentence will run concurrently to the jail term at the more serious case.