Fans of the HBO show Girls may have been surprised to see an OCD storyline introduced last week. We learned that Hannah, the character played by the show’s creator and head writer Lena Dunham, was diagnosed with obsessive-compulsive disorder as a child and is having a relapse now, brought on by a recent breakup and stress over her book deal.

Hannah is falling back into an old anxious habit of doing things in increments of eight (open the front door eight times, eat eight chips, even bump into a stranger eight times at a restaurant), counting as she goes along. As luck would have it her parents are in town, and they noticed her old compulsion immediately.

What follows is a thoughtful and realistic depiction of what it can be like when young adults are dealing with mental illness. Her father reverts to baby talk, calling the flare up “getting county” and wants her to come back home and consult her pediatrician. Meanwhile Hannah, who is having a hard time admitting even to herself that her OCD is back, resents her parents’ interference and tries to convince them that she is in control. When she gets coerced into treatment she tells her psychiatrist, “I will really do anything you say if you tell my parents I’m okay” instead of facing the fact that she needs help.

The downward spiral continued in Sunday night’s episode, when one of her compulsions put her in the emergency room, and in a preview for next week’s episode her father accuses her of not taking her medication.

It’s a good illustration of how a psychiatric disorder can threaten hard-won autonomy and undermine a fragile self-image. Disorders like OCD can be very successfully managed, but they can also recur. Acknowledging that old, unwanted behavior patterns are back is the first painful step to mastering them again.

The sensitivity of this plot line comes in part from the fact that Lena Dunham has struggled with OCD in real life. In an interview Dunham said:

It’s something that I’ve struggled with so I feel as though I am able to shed a certain kind of light on the experience and do something that doesn’t necessarily feel cookie cutter. One of my biggest pet peeves is when people go like, ‘I just love it when my room’s clean; I’m so OCD!’ It’s like, actually no, you’re just a neat person and not a slob animal.

So far the show has done a great job of doing that, and I’ve even seen several Girls-inspired OCD primers popping up across the Internet. (Here’s one great example.) Mental illness portrayed right in the media is a rarity, and seeing it on a popular show that gets people talking is good for everybody.