Twin Peaks actors Dana Ashbrook, Sheryl Lee, and Lenny Von Dohlen in the Psych homage. Photo: Alan Zenuk/NBC/NBCU Photo Bank via Getty Images

“Who killed Paula Merrell?”

That’s the question begged by an anonymous emailer a few minutes into “Dual Spires,” an episode roughly halfway through the fifth season of USA’s long-running series Psych. If viewers weren’t familiar with a particular ’90s seminal drama bearing a striking resemblance to a few rapid-fire opening motifs — the aforementioned dead girl’s body discovered wrapped in plastic by a body of water; a few asides about the disputed merits of silent window shades; a newspaper called The Great Northern — this might’ve seemed like a slightly more dramatic installment of the popular USA dramedy. But, as many quickly realized, this was actually a Very Special Episode: an expertly executed homage to David Lynch and Mark Frost’s Twin Peaks.

“As soon as I knew we were going to be doing tribute episodes, and as soon as I knew the landscape of Psych allowed us to do homages, the show creator and I both had respective dreams. His was a musical episode, and mine was a Twin Peaks episode,” James Roday recently explained to Vulture, who starred in the series as psychic detective Shawn Spencer and co-wrote the episode. “It was crazy, because I was the superfan on staff and the amount of freedom that was given to me, both by USA and Universal, was pretty remarkable. They were like, ‘You’re the one who knows the show, go and try to make this happen.’ I couldn’t believe we were going to do this.”

While executing a homage to such an iconic TV series might seem daunting, the process was surprisingly easy for the Psych team. Roday was tasked with filling the script with as many Twin Peaks references as humanly possible — “it was definitely the more the merrier” — and he recruited frequent Psych writer Bill Callahan to form the mystery and keep the narrative moving. What ensued was a central story line that involved the drowning murder of a local teenage girl, whose body is discovered during Dual Spires’ annual Cinnamon Festival. Shawn and his crime-solving partner Gus (Dulé Hill) are invited to the secluded and quirky town under the guise of attending the festival, but the true motivations for their summons — solving the murder — are eventually revealed via an email address at underthenail.com. (Get it?)

“I did decide that I’m going to focus primarily on the first 15 episodes, because I feel like that, for me, is the seminal part of the Twin Peaks magic carpet ride,” Roday said. “I decided to stick with the town, and Laura, and solving her murder as much as possible, because that’s the stuff casual fans appreciate the most. And then I tried to throw in late-game stuff so the super die-hard fans could appreciate that, too.”

Sherilyn Fenn, in her element. Photo: Alan Zenuk/NBC/NBCU Photo Bank via Getty Images

Of course, a script can only do so much. Psych needed guest stars to give the episode a bona fide Twin Peaks seal of approval, so Roday opened up his handy Rolodex. “I called my good friend Dana Ashbrook, who was the linchpin of putting the cast elements together,” he explained. Ashbrook, as any casual Twins Peaks fan will tell you, played the troublemaking Bobby Briggs in the original series. “Not everybody knew Psych and not everybody knew to trust that it was going to be a love letter and not some kind of screwup. So it was Dana’s job to tell everybody, ‘Guys, Roday is legit. This is totally legit and it’s going to be good and there’s nothing to worry about.’” One at a time, others followed: Sherilyn Fenn, Sheryl Lee, Robyn Lively, Lenny Von Dohlen, Catherine E. Coulson, and Ray Wise (who already had a recurring role on Psych) all ultimately signed on for various roles we won’t spoil here. (Mädchen Amick was initially booked for Lively’s role, but due to an unexpected family matter, she had to pull out.) Even Twin Peaks’ dream-pop chanteuse, Julee Cruise, agreed to reinterpret Psych’s theme song for the episode — and the ending scene fades out with her 1993 Angelo Badalamenti–arranged toe-tapper “Kool Kat Walk.”

Catherine Coulson and her beloved log. Photo: Alan Zenuk/NBC/NBCU Photo Bank via Getty Images

Like all of Psych’s episodes, filming took place in Vancouver, and it was during the first day on set when Roday realized the significance of his feat, which has only grown since the announcement of the Twin Peaks revival. (Not to mention, the “privileged” feeling of working with Coulson, who has since passed away.) “There was such a tenderness to the way all of them hold that experience and hold that material. You just knew you were a part of something special while it was happening. Having all of those people in the same place and creating that energy was really palpable,” Roday explained. “It wasn’t like, Oh, I’ll schlep up to Vancouver for all of those days and do this thing. It was an experience. What we didn’t realize is that a lot of them hadn’t seen each other for a long time. Sherilyn and Sheryl saw each other for the first time in 15 years, and they both burst into tears. Everybody felt it. I like to think, in any small way, it played a role in letting Showtime know that there’s still an appetite out there for that show. I feel like that’s my legacy.”

Though David Lynch wasn’t involved in the making of the episode, Roday eventually received what’s arguably the next best thing: the auteur’s stamp of approval. “After the episode aired, his daughter Jennifer directed a couple of Psych episodes and has become a friend. She insinuated that he had seen it at some point and he was pleased. That was pretty awesome.” Sadly, Roday’s homage-writing prowess didn’t get his name on the revival’s overflowing cast list. “It wasn’t for a lack of trying,” he said. “Trust me.”

“Dual Spires” is available for purchase on Amazon, iTunes, Google Play, and Vudu.