[Warning: This story contains spoilers from Sunday's episode of Curb Your Enthusiasm, "The Shucker."]

Pop culture worlds collided in Sunday's supersized Curb Your Enthusiasm, the penultimate episode of Larry David's comeback season of the HBO comedy.

David and executive producer Jeff Schaffer pulled off two major cameos that managed to stay a secret until Sunday's show. One, a hinted-at visit from Lin-Manuel Miranda, as the world-famous star is the only actor the Muftis wanted to see starring in David's Fatwa! The Musical if they allowed it to go on from last week's episode; and the second was a visit to the set of Judge Judy so the TV Larry David could settle a grievance with the former owner of his house. The episode also crammed in a break-up with the likable Bridget (Lauren Graham), a fake episode of a Chicago-themed NBC show (starring Jerry O'Connell and Ali Larter) and a first-time affair for Susie Greene (Susie Essman). Most impressively, however, Miranda's storyline required Curb to film a Hamilton performance — so Larry could fall asleep while sitting next to Miranda's wife (played by America Ferrera).

"We just told them to perform in their normal brilliant way and that we're just going to answer the question: What kind of animal falls asleep in Hamilton? That animal is Larry David," Schaffer, who also directed the episode that was co-written by Oscar winner Justin Hurwitz, tells The Hollywood Reporter about pulling off the performance scene with the Los Angeles and San Francisco cast of the megahit show. But, despite David snoozing on Mrs. Miranda's shoulder because he took too many pain pills, Miranda will return next week during the season finale to continue David's Fatwa production. "Lin will probably find out from his wife that Larry fell asleep, but it's not enough to stop the Fatwa! train from moving ahead," he adds.

The entire ninth season has been building to the Fatwa! production, which now appears to be taking on a hip-hopera twist thanks to Miranda's involvement and much to Larry's dismay. Will the finale bring with it the finished Fatwa! The Musical? "That seems like a fantastic reason to tune in," hints Schaffer. Below, the Curb boss reveals how they pulled off all those cameos, drops a tease or two about next week's season ender (which clocks in at just under 60 minutes) and gives his very Curb-like answer to the episode's biggest unanswered question: What happened in Tahoe?

You have been teasing a couple of big guest stars that you wrote into the show before checking if they were even available. Were Lin-Manuel Miranda and Judge Judy those special guests?

Yes. We knew we wanted to have Lin and we wrote this episode and some stuff that's coming up for Lin. Then we just needed to do one thing, which was see if Lin was interested or available. (Laughs.) You think that the hard part is actually writing the shows, but then you realize that once you've written it, and you've written it for someone specific, that you then need that person. Scheduling becomes the hardest thing, because he's one of the most sought-after people on the planet. Luckily, he's a fan of the show and was super excited to do it. The only problem was that he was going to be shooting Mary Poppins for the entirety of our shoot, in England. Once again, we had no actual plan B. We just figured it was going to work. All of the Lin scenes in this episode were shot on a day in February because he was in town for the Oscars. It was all shot two days before the Oscars because he happened to be in town because he was nominated. We said, "While you're here getting honored, let's do a day!" Then we had to wait six months, until the end of June, to shoot him again for the finale.

Miranda said he met Larry David when David was on Broadway doing his show, Fish in the Dark. Had they kept in touch? And how did Miranda react to your pitch?

They did meet then. Larry is a huge fan of Lin's, and Lin, luckily, is a huge fan of Larry's. So everybody wanted it to work out and somehow, it did. I really, truly don't know what we would have done if he had just said, "Nah, I'm good fellas." He gave us enough time to do everything we needed, very generously. We wanted to do a lot with him so they were some packed days.

It seems that Miranda enjoys shattering his nice-guy image when appearing on TV. Did he enjoy playing himself, but a more controlling and bossy version?

Lin was totally in when we pitched him, and he was so happy to play a different version of himself. The real Lin is fun and brilliant and has all the talent to one day make it big — if he ever gets a break. (Laughs.) He's one of the most fun people you can ever work with. And this version of Lin is very happy to get in Larry's persnickety sandbox and get dirty. This version is just killing Larry but with a smile, and is so graciously condescending to Larry. There is a line after he has completely taken over the entire meeting and direction of the play and he says to Larry, "Go sit back down over there, you're doing great." Larry has done nothing. He hasn't let Larry do a thing at all. He's such a brilliant improviser. He was having a great time with Larry and it shows, and you're going to see more of their incredible dynamic next week.

Both Larry and Lin-Manuel sang and rapped, respectively, some of the opener to Fatwa! The Musical. Did each of them write those verses?

You're starting to see a little bit of the music of the musical. Larry's opening song, "There's a Fatwa," was actually written by us for the premiere and we didn't use it. We know what Larry's version of that song was, and because we didn't want to put a lot of pressure on Lin when he was coming in, we wrote up some versions for Lin to do. Lin wisely said, "You know what, I think I'll just freestyle it." And he did, and every take was different and brilliant. It was like watching someone dunk. You just sit back and go, "Well, I'll never be able to do that." Lin just verbally dunked on us. And, by the way, there were so many funny lines he added that we would have never thought of. The "F is for 'fucking awesome'" with F. Murray Abraham line and the "The verses are going to be Satanic" line — that's all Lin. He is a seriously funny person. Larry had no idea that was coming.

Is he turning Fatwa! The Musical into a hip-hop opera?

Larry gets a meeting with Lin but wants to keep creative control, and that goes out the window because of the boss desk. This is a story where the origins are in-house. For a lot of convoluted reasons, my office has Bobby Farrelly's desk. It's a massive and muscular piece of wooden steel. My office also has the big dry-erase board where we do a lot of our outlining, and Larry started joking that my ideas had more weight because I was sitting behind this massive desk. When it came time for Larry, Jeff and Lin to meet up, it had to be about that desk. We shot that scene and all the agency stuff at UTA during their regular work day. So the assistants you see are real agency assistants, and we shot in my agent David Kramer's office — he and [CEO] Jeremy Zimmer were beyond generous in letting us use the agency three days before the Oscars. I thanked David Kramer and then the second thing I said was, "We need to get rid of all your furniture, we need something more masculine." The entire UTA, from agents to assistants, were unbelievably cool in keeping this a secret since February.

When you have someone like Miranda, which then spans out to include his wife, played by America Ferrera, and people at a Hollywood agency, how do you keep the cameo a secret?

I was actually emailing with Lin two weeks ago to tell him his shows were coming up. He said, "It's unbelievable, I've heard nothing about me being on the show. I love it." We knew we wanted to keep it a secret, and it actually happened. It didn't get out. Huge props to everyone at UTA for actually not saying anything just because we asked them not to. UTA: An agency you can trust! They were literally trying to work when we filmed, as Larry and Lin are running through the hallways. No one wants Larry mad at them.

Since Lin has all the creative control now, will you be reaching out to F. Murray Abraham, instead of Mandy Patinkin, to play the Ayatollah in Fatwa!?

As we move on to the finale, the musical looks like it is moving forward. All of Larry's friends are invested in it, and Larry has lost creative control. Larry is having a true Hollywood experience. His dream is coming true, but he's lost creative control. But! He's lost creative control to a genius so this just might work.

Is the real Larry David a Hamilton fan?

The real Larry David has seen Hamilton three times and hasn't fallen asleep even once! I saw it with him for his second time, and I can say that he was 100 percent engaged the entire time. His head never drifted onto my shoulder.

How did you manage to film the Hamilton performance scene?

We had a few big asks for this episode. (Laughs.) One was, "Hey Lin, are you available for this episode in February?" Then we shot him more in June and told him that for the end of the ninth show, we really needed to go to Hamilton. We didn't want to ask right at the top because we already were taking up so much of his time — it would have been in very poor form to frontload all of our requests. So we actually waited on that, and that was the last scene of the season that we shot because we had to wait for Hamilton to come to Los Angeles.

You also directed this episode. What was it like to helm a mini-Hamilton production within a Curb show?

We were able to film the cast in the afternoon before a show. It's movie magic! We shot facing away from the stage first with our own extras, because we can make them sign NDAs. Then the Hamilton cast came in and we shot the other way with them. They were all very, very excited to be on Curb. I don't think they realized how excited we were to sit there and watch Hamilton! They were performing and then we started to ask them to do a little more, like scream from the stage. They were totally into it. Hamilton was very, very generous to let us shoot a little bit of their performance. We got to see little bits of two songs, a bit of "Alexander Hamilton" and then 30 seconds of the battle of "Yorktown." The first time we did that, there was a little bit of confusion about who was going to tell the cast to stop. I was directing but there was someone in charge of the cast and the musicians kept playing, so the cast kept singing. We we're all watching and really enjoying it thinking, "We can't use this but I'm really glad we get to see the entire battle of 'Yorktown!'" The thing about shooting performances is that it's actually very easy because the cast does it the same brilliant way every time. It's actually the exact opposite of how we shoot Curb, where every take is like a live sporting event.

How did Ferrera's casting come about as Lin's wife and will she be back for the finale?

Wait and see. But once Lin agreed to do it we knew we needed a scene with his wife. We asked him if he wanted to ask Vanessa [Nadal], or if there was someone else he wanted to play her. He asked his wife and Vanessa said, "Just get America." They are friends and that worked out perfectly, because Lin and America are super close.

Jerry O'Connell and Ali Larter also made quick guest appearances for the fake NBC show, Chicago Homicide. Can you talk about making that show within your show?

Bridget's [Graham] an NBC censor and we wanted to see her at work. That meant we had to have a real-looking NBC show that Larry watches on the show. We needed some star power, so it felt like a real network show, and Jerry and Ali were very sweet to lend their star power. I told both of them this was not their one shot to be on Curb, because they were so great we want to have them back. The reason we couldn't use a real show is because we needed to see a cut that had swear words in it and an unauthorized penis. You see a little bit of it but there's a lot more of attractive people solving crimes in Chicago that will be posted online. We shot it on the same day as Judge Judy, in an alley on the same lot.

The other big stunt of the episode was bringing Larry to the Judge Judy courtroom. Larry sues Rose Shapiro (Carol Herman) for trespassing at his home and stealing his ficus plant, and she countersues him for sole custody of the plant on grounds of plant abuse — and Rose wins. Is the honorable Judge Judith Sheindlin a Larry David fan?

Larry always thought it would be very funny for him to appear on Judge Judy. He also knows her. They are somehow step-related — she is somehow related to people on Larry's ex's side of the family. He always thought it would be funny to appear on the show, and I have to say, sitting in the Judge Judy control room and seeing Larry and Leon [J.B. Smoove] on those monitors was a ridiculous, "How the hell did we get here?" experience.

There was a brief moment where J.B. Smoove, and David too, looked like he might break. How many takes did you get?

They were doing their show and we basically had an hour after they finished taping. They let us use their camera crews so it looked like the show. Judy was nice enough to let us do it, she was into it. We're also there at the end of their day, so after we did one take Judy said, "I hope you got everything because I'll give you one more." (Laughs.) She's the boss, it's her show. You're in her courtroom and you just go, "Yes, ma'am." There are so many takes where Larry is just laughing at the fact that he's there arguing with Judge Judy.

How did you keep the Judge Judy visit a secret?

It was the same thing. We said, "Hey, this is going to be an amazing surprise." Judy was totally happy to have it as a surprise and understood how funny it would be for the audience to see that he actually went on the show. She watches Curb, and it was fun to watch her and Larry go at it. Larry finally met his match with Judge Judy.

Larry does deliver an NDA on-camera — a no-sex and gossiping contract to Bridget (Graham) that sends her running. Are Larry and Bridget officially done this time?

Yes, I'm sad to say. Lauren Graham and Larry's TV relationship has finally ended. I know people thought it was going to be over after last week, but once Larry vanished for a little bit to the Mufti tribunal and was actually gone, she was worried about him and just so happy that he was back and alive. That was something we had discussed and shot, but ended cutting for time. She went through a lot — dating Larry is fraught with peril. She went through almost one major thing per episode, but the sex NDA was finally the Larry straw that broke the Bridget back.

She also called back a nickname of Larry's when gossiping to her friend about "Larry Longballs." Wasn't Leon (Smoove) the first to deem him "Longball Larry"?

A lot of people thought "Larry Longballs" was a new thing, but that's an established trait of Larry David. Larry's long balls were a callback to the TiVo guy from season six where Larry's balls got caught in the open fly of his underwear because they were too long. Larry and Bridget are dating and Bridget clearly loves talking about her exes, and Larry's fear is that when things go south, as they inevitably do, that she will start talking about Larry's escapades. It just seems natural that if she is going to be talking out of school that she would bring up one anatomical trait that we've already established.

Now on to the biggest unanswered question of the episode: What happened in Tahoe?

(Laughs.) If I'm going to talk Tahoe, which I really shouldn't, what I will say is that there is an extended scene where Leon has his own theories about what happened in Tahoe that we're going to put online. But I will warn you, Leon's theories about what happened in Tahoe are mostly small watercraft-based, featuring Leon's extensive and inaccurate theories about kayaks, canoes and rowboats and how they can be used in a sexual nature. We're also going to post online some extra footage of Leon and his very vivid theories about how to heal a sprained dick (below). But, as to what really happened in Tahoe, that's best left up to the imagination. Once you know what happened in Tahoe, you won't be talking Tahoe anymore. One of Larry's biggest fears is that people around him will be talking Tahoe. I think if you asked Larry and you asked me what happened in Tahoe we would give you two separate answers, but neither are good.

How To Fix A Broken Dick | Curb Deleted Scene 909 Step 1: Boil ginger ale. At that point, does there need to be a Step 2? Posted by Curb Your Enthusiasm on Monday, November 27, 2017

Susie (Essman) is shown having her own affair for the first time, with another guest star, Steven Weber's shucker. Are we to assume she has always been straying and if not, why now?

This is the first time we've seen Susie stray outside the wonderful marriage that she is in with Jeff Greene [Jeff Garlin]. We've already seen earlier in the season with the house that she can counter Jeff's roving eye with her watchful one. Now she's showing that two can play at the game that takes two people to play. I think Susie has a thing for cowboys. There's no accounting for taste.

Next week brings Sammi Greene's (Ashly Holloway) wedding to Victor (Chet Hanks). Will more come to pass between Susie and Jeff, now that her transgression has been revealed? What else can we expect? More callbacks and surprises?

Next week is the culmination of everything we've set up. Sammi is getting married to Victor, our war veteran. Fatwa! The Musical looks like it's moving ahead. We'll see what happens!

This episode clocked in at 45 minutes. Was this the longest ever, until next week's finale?

The longest episode ever, I think, was "Opening Night" back in season four, that was almost 60 minutes long. Next week clocks in at under an hour, but it's bigger than this one. We're trying to wrap up everything and there are a few extra-special reasons why it's long. There are things that we definitely wanted to play all the way through.

You haven't announced anything about another season, yet. How will next week function as both a season and a series finale, if it came to that?

The end of next week's episode could easily be the final Curb ever — or not. It's built that it could go either way. In Curb-land, season finales are usually series finales in Larry's mind. How could he ever do another episode? Where are those ideas going to come from? Larry is the only one who doubts he'll ever have another good story for the show. So when we wrote this season finale, our goal was to come up with a good ending that could easily be the final Curb scene ever ... or not. It will all depend on what Larry wants to do. But I personally wouldn't bet on him running out of ideas. Documenting the indiscretions of the selfish and the petty is an evergreen business.

What did you think of the penultimate episode of the season? Tell THR in the comments below and check back in with Live Feed next week for a final chat with Schaffer after the season finale airs Sunday at 10 p.m. on HBO.