Robert F. Kennedy’s granddaughter Saoirse Kennedy Hill once spoke about battling depression and attempting to take her own life in a first-person piece for her high school newspaper.

The 22-year-old died Thursday afternoon of an apparent overdose at her family’s Cape Cod compound.

“My depression took root in the beginning of my middle school years and will be with me for the rest of my life,” Saoirse wrote in a 2016 piece for the Deerfield Scroll, the school newspaper of Deerfield Academy in Deerfield, Massachusetts.

“Although I was mostly a happy child, I suffered bouts of deep sadness that felt like a heavy boulder on my chest,” she said. “These bouts would come and go, but they did not outwardly affect me until I was a new sophomore at Deerfield.”

Saoirse, the daughter of Courtney Kennedy Hill, said she began “isolating” herself in her room, “pulling away” from her relationships with friends and loved ones and “giving up on school work.”

“We all know that some people find winter at Deerfield lonely, dark, and long,” she explained. “During the last few weeks of spring term, my sadness surrounded me constantly. But that summer after my sophomore year, my friend depression rarely came around anymore, and I was thankful for her absence.”

Two weeks before her junior year, however, the bouts of sadness came back.

“My sense of well-being was already compromised, and I totally lost it after someone I knew and loved broke serious sexual boundaries with me,” Saoirse said. “I did the worst thing a victim can do, and I pretended it hadn’t happened. This all became too much, and I attempted to take my own life.”

Saoirse said she returned to school for the fall of her junior year, but “realized” that she “could not handle the stresses Deerfield presented.”

“I went to treatment for my depression and returned to the valley for my senior year,” she recalled. “I didn’t care that students thought that I had left because of an eating disorder, or that I had been bullied, but it concerned me that my teachers and advisors didn’t know what I had been going through. Even though it was helpful for me to discuss my struggles with all of those important people in my life, it was still uncomfortable, and it was hard for me to take the initiative.”

Saoirse described Deerfield as “one of the top educational institutions in the country,” but blasted faculty and staff for not knowing “how to talk about mental illness.”

She claimed she saw a “stark contrast” between her out-of-school treatment facility and her experience at the school — and said their doctors had no idea what she had been going through.

“Although my friends were extremely supportive, they seemed to be the only ones who knew what had been going on in my life for the past year,” she wrote.

“Dr. Josh Relin, Director of Counseling at Deerfield, has explained to me that federal laws designed to protect patient privacy constrain what information can be shared in workplaces and schools,” Saoirse said, quoting him.

“There is a strong firewall between what happens in the Health Center and the other adults in the community due to HIPAA (Health Insurance Portability and Accountability Act),” she remembered him saying. “This law determines how health information can and cannot be shared.”

“HIPAA was designed to protect patient privacy, yet in my experience, it left me feeling very much alone,” Saoirse added. “In the future, I hope that the Health Center reaches out to students before they return from medical leave in order to discuss how the school can make their adjustment back to Deerfield less difficult. If they had reached out to me, I would have let them know that I wanted my circumstances shared with my teachers and advisors before I returned to campus; this would have made my transition back a lot easier.”

The young woman was found at the Kennedy retreat in Hyannis Port on Thursday afternoon, suffering from what family friends said was a drug overdose. She was pronounced dead at Cape Cod Hospital.

It was not immediately clear whether Saoirse had intended to take her own life.

“Many people are suffering, but because many people feel uncomfortable talking about it, no one is aware of the sufferers,” she wrote in 2016. “This leaves people feeling even more alone.”

Saoirse called “on all members of the Deerfield community to come forward and talk freely about mental health issues” so they wouldn’t feel the way she did.

“We are all either struggling or know someone who is battling an illness,” she said. “Let’s come together to make our community more inclusive and comfortable.”