The 16-year-old had an infected hairball in her digestive system, suggesting that she may have had this mysterious and rare disorder.

A teenager in England is raising money for the family of her best friend, who died suddenly at college earlier this month. While the unexpected loss of a 16-year-old is tragic no matter how it happens, it’s the cause of Jasmine Beever’s death that’s making headlines.

According to LinconshireLive, an autopsy revealed that Beever had an infected hairball in her stomach, which became inflamed and caused an ulcer. The ulcer burst and “shut down her vital organs,” the news site reported, causing her to collapse. Beever was briefly revived at the hospital, but passed away shortly after.

No additional details about Beever’s death, or her overall health before she died, have been reported. But some media organizations have speculated that the teen suffered from a condition called Rapunzel syndrome, in which a mass of hair forms in the stomach and part of it—described in medical literature as a long tail—passes into the intestine.

So what exactly is this syndrome, and why does it happen? For starters, it’s very rare: Only about 30 cases have been written about it since it was first identified (and named for the fairy-tale princess with the long golden locks) in 1968.

If a hairball in the stomach doesn’t extend to the intestines, it’s not technically Rapunzel syndrome. But no matter where they are in the digestive system, these masses of hair—called trichobezoars—can still cause problems. When they do, it’s almost always in teenage girls who have a condition called trichophagia: the compulsive eating of one’s own hair.

Trichophagia is related to another psychiatric disorder known as trichotillomania, which is described as the urge to pull out one’s hair. Only about 30% of people who have trichotillomania will eat their hair, according to medical research, and only about 1% ingest enough hair to cause medical complications or require surgical removal.

Trichotillomania, or hair-pulling disorder, is described in the Diagnostic and Statistical Manual of Mental Disorders (DSM–5)—the go-to reference manual for mental-health professionals—as a condition related to obsessive-compulsive disorder. (There’s no entry for trichophagia specifically, but the two are often lumped together.)

According to a report by Dirk Elston, MD, chief of dermatology at the Medical University of South Carolina, hair-pulling and hair-eating may be related to a chemical imbalance or structural abnormalities in the brain; it may also run in families, either because of genetic or environmental factors. People who engage in these behaviors often use them as a coping mechanism for stressful events, but they may also do them absent-mindedly—while watching television or driving, for example.

Hair-pulling typically results in visible hair loss and psychological distress, while hair-eating can cause serious medical problems including anemia, abdominal pain, bowel obstruction or perforation, and internal bleeding. Surgery may be required to remove hairballs from the digestive system.

To get our best wellness tips delivered to you inbox, sign up for the Healthy Living newsletter

Treatment for hair-pulling and hair-eating usually involves behavioral therapies with a psychologist or psychiatrist. Antidepressants and other psychiatric medications may be helpful, although no drugs are approved specifically for the condition.

It’s important to keep in mind that trichotillomania and trichophagia are more than just harmless nervous tics, like occasionally twisting or pulling your hair when you’re stressed. If you or someone you love has a serious problem that’s resulting in hair loss or other medical symptoms, talk to your doctor or a mental-health professional.