The drug that sleepwalkers tend to start with is the anti-anxiety medication clonazepam, Gehrman said. It's not clear why it works, but it may help people relax and sleep more deeply.

Clonazepam is also prescribed for REM behavior disorder, although it is sometimes not appropriate in older patients because it may aggravate sleep apnea, Pelayo said. There's evidence that the hormone melatonin can be effective.

Some people don't respond to any medications for sleepwalking, Gehrman said. It may help to put a bell on the door so that if they try to leave the bedroom, they will wake up -- or at least their bed partner will, he said.

In extreme cases, people need restraints so that they can't get out of bed during the night, Gehrman said -- something that attaches them to the bed in such a way that only someone who is awake could undo it.

Birbiglia has said in interviews that, as with his alter ego in the film, he takes medication and sleeps in a sleeping bag, and he used to wear mittens so that he couldn't open the bag.

Gehrman hasn't had any patients who have tried the bag-and-mittens method but noted, "You have to be creative sometimes."

Experts say there isn't a lot of research going on into sleepwalking or REM behavior disorder treatments since the available resources are sufficient in most people.

The next step in REM behavior disorder is exploring the connection to Parkinson's disease, Pelayo said. It may be possible to identify patients for whom the sleep disorder is a risk factor for Parkinson's and treat them before the disease gets worse.