On first glance, it may not seem as though Christopher Nolan’s World War II epic Dunkirk and the pilot episode of the ABC mockumentary series Modern Family have anything in common. One is a visceral recreation of the horrors of war; the other is a lighthearted family sitcom.

But they both use the same storytelling technique to keep the audience engaged with the characters from beginning to end. Both Dunkirk and the Modern Family pilot introduce three sets of unrelated characters and wait until the very end to reveal how they all connect to each other.

RELATED: The Prestige Features Christopher Nolan's Best Twist Ending

In Dunkirk, arguably Nolan’s most intense and emotionally resonant film, we’re introduced to three lead protagonists: Fionn Whitehead on the land as Tommy; Mark Rylance at sea as Mr. Dawson; and Tom Hardy in the air as Farrier. Tommy is a young soldier who’s been shipped off to fight and desperately wants to leave the Nazi-occupied warzone and go home; Mr. Dawson is an aging civilian sailing his leisure yacht into the belly of the beast to help out any way he can; and Farrier is a fighter pilot picking off German bombers from 50,000 feet in the air. As usual, Nolan uses the film to manipulate time, setting the three parallel stories across different timelines. The land sequences take place across a week; the seabound sequences take place across a day; and the airborne sequences take place across an hour.

Soldiers in Christopher Nolan's Dunkirk

In the pilot episode of Modern Family, the first of many airtight scripts deftly juggling the show’s massive 11-piece ensemble and giving each cast member plenty of material to chew on, we’re introduced to three different family units: Phil, Claire, and their three kids, a traditional nuclear family; middle-aged Jay, his second wife Gloria, and her son from a previous marriage, Manny; and Mitch and Cam, a same-sex couple with a newly adopted Vietnamese baby, Lily. While these characters all convene with each other regularly in every subsequent episode, they’re kept apart for the majority of the pilot. Phil and Claire contend with the arrival of Haley’s first boyfriend, Jay and Gloria comfort Manny after an older girl rejects him, and Mitch and Cam bring Lily home for the first time.

Both the Dunkirk screenplay, Christopher Nolan’s first solo writing credit on an original screenplay since Inception, and the Modern Family teleplay, credited to series creators Steven Levitan and Christopher Lloyd, wait until their climactic scenes to reveal the connections between the main characters. Modern Family’s use of this technique is more obvious, as the three families meet at Mitch and Cam’s house to be introduced to their new baby, revealing that they’re not three separate families after all; they’re all one big Dunphy-Pritchett-Delgado-Tucker clan.

After the rest of the pilot had set up the show to be an in-universe documentary capturing the lives of three separate sets of parents raising their kids, the final scene suddenly revealed all these characters to be part of the same family. In later seasons, the mockumentary element was quietly scrapped. The interviews, shaky camerawork, and awkward looks to the camera all remained, but the show stopped acknowledging the cameras directly. Instead of embracing the documentary as a part of the show’s universe like The Office, Modern Family used it merely as a stylistic flourish like Parks and Recreation. Both are valid approaches: The Office stuck the landing with the release of its in-universe documentary and its cast becoming minor celebrities in the back end of the final season, but that kind of storyline could easily fall down the meta rabbit hole, so ignoring it was a wise move.

The family gathers around Lily in the Modern Family pilot

The climactic scene in Dunkirk does the same thing as the Modern Family pilot. When the final stages of the evacuation are underway, the movie’s three timelines converge to reveal how Tommy, Mr. Dawson, and Farrier all touch each other’s lives. Tommy narrowly manages to escape as Mr. Dawson’s yacht arrives (along with the yachts of a bunch of other concerned citizens who stepped up to the plate), then Farrier swoops in to save everybody – including Tommy and Mr. Dawson – from a German bomber doubling back to attack.

By the time Dunkirk and Modern Family establish the connections between their characters, the audience has gotten used to the idea that they’re not connected at all, so the revelation comes as a delightful surprise. As an audience member, it’s extremely satisfying when a story can pull off this technique as effectively as Dunkirk and Modern Family did.

The on-screen carnage in Dunkirk feels messy and spontaneous and unpredictable – harking back to the blood-soaked traditions of genre greats like Hamburger Hill and Saving Private Ryan – but Nolan’s meticulous story structure ensures that the audience is in safe hands and the movie never devolves into a loud, brainless actioner. Revealing that the many main characters introduced in the Modern Family pilot are all related made it a lot less daunting for viewers to tune back in the following week. The first episode of the show hides what the show really is until the very end, which intrigued audiences enough to keep them coming back for another 11 seasons.

MORE: Christopher Nolan Talks Making His Movies Into Video Games