To all sides, Grant Shea's downfall was "a tragedy."

Assistant U.S. Attorney James Petkun first voiced those words at a sentencing hearing Wednesday for Shea, who held a high position in Philadelphia city government and helped people — but in "the darkness of his home" traded images of child pornography.

The defense agreed. Even U.S. District Judge Nitza I. Quiñones Alejandro called it "a tragedy" and said that the sentencing "has been a struggle for me as well as everyone in this courtroom. It is not an easy decision, what has to be done."

She then sentenced Shea to 16 years in federal prison, followed by 20 years of supervised release.

Shea, 30, a former program manager at the Philadelphia Office of Emergency Management, pleaded guilty last July 24 to two counts each of receipt, possession, and distribution of child pornography. An FBI investigation found that he had thousands of images and videos of child porn on his laptop computers and a cellphone.

Petkun, the prosecutor, read a letter written by the mother of three boys who were raped by a man and whose images were shared on the internet. When a "deranged pervert posts and reposts these images … ," the letter said, "the nightmare occurs over and over again."

"This isn't like a fraud case where a person makes a choice," Petkun told the judge. "It's a part of who he is. … People can't control themselves."

Defense attorney Richard J. Fuschino Jr., who has been representing Shea with lawyer William J. Brennan, called Shea "a phenomenal member of our community."

But Fuschino also said "there is no doubt he [Shea] failed tremendously" and needs treatment.

About 35 people had submitted letters of support for Shea to the judge. Eight people came to the hearing, and five spoke, including his parents, who told the judge how "difficult" this has been, but said that they support their son and that he is remorseful.

Simone Allender, who called Shea her best friend, described him as "a man who is growing and wanting to understand himself better and wanting to do better."

Shea served as the health and human services program manager at the office for five months until he resigned July 14, 2016, when he was charged in a federal indictment with one count each of receipt, possession, and distribution of child pornography.

He was charged in a second indictment in May 2017 after the FBI, while reviewing evidence seized during an unrelated investigation, discovered that Shea tried to solicit child porn in November 2016 while on house arrest awaiting trial.

For his part, Shea, dressed in a forest-green prison jumpsuit, apologized in a loud voice for his actions.

"There was a point in time when I thought I was not hurting anyone," he said. "I have come to recognize that there are in fact real victims."

He said he would commit himself to obtaining treatment and "will never do this again."