This has been a wonderful year so far for Roger Federer, but late Thursday afternoon at the Miami Open, when he found himself down 6-4 in a third-set tiebreaker against fellow quarterfinalist Tomas Berdych, Federer thought, “This isn’t fun anymore.”

Berdych has a massive serve and an atomic forehand. Both had done plenty of damage to the Federer brand already during the sun-shot afternoon, threatening to spoil that much-anticipated potential final showdown between the Swiss icon and his lifelong rival, Rafael Nadal.

Somehow, Berdych vs. Nadal doesn’t have quite the same ring.

At times in the past, Federer said later, he might already have been “mentally on the plane,” writing off the loss to Berdych, moving on the next tournament. But not this time. Not in this, his year of living miraculously.

Federer has been gorging on wins in 2017 (he’s 17-1), settling old scores (he finally managed to record a third consecutive win against Nadal) and reveling in the adulation that has greeted his remarkable rebound from knee surgery in the spring of 2016.

He doesn’t want to see that end. Why should he settle for a quarterfinal loss, when a win here in Miami would take him one step closer to completing a Sunshine Slam (back-to-back wins in the Indian Wells and Miami Masters). If he did that, he could put his feet up and contemplate deep questions, like how the accomplishment compares with the last time he did it, 11 years ago.

The plane could wait on the runway in his mind.

On the first match point against him, Berdych drove a nervous forehand into the net. It turned out to be his best — and only — chance because Federer would serve the next two points. A precise unreturnable serve and an ace flipped the terms, leaving Federer up 7-6. The series of events was dispiriting enough to goad Berdych into a double fault to end the match.

“I enjoy playing tiebreakers,” Federer said in his on-court interview, after completing the 6-2, 3-6, 7-6 (6) win. “They’re sometimes what wins you tournaments.”

Add another improbable chapter to the saga of a glorious year in which Federer, 35 years old and returning from a long layoff because of knee surgery, has turned into a runaway train. His confidence is soaring, and that has produced a plethora of advantages.

Federer finds fresh spring in his legs at times, such as the end of the second set Thursday, when it appears that the ankle weights of time are buckled on. He finds the ace that leaves his opponent gazing, with feet planted, hard on the heels of a patch of poor serving. He knows it’s never too late to turn things around, no matter how desperate the straits, and he knows from a vast store of experience just how to affect that reversal.

“I believed I could turn it around, I was feeling it,” Federer said. “Whereas in other matches, when you don’t feel it, sometimes you’re like mentally at the plane already. Maybe you think, ‘You never know.’ But things never turn around if you give it the old ‘never know’ play.”

The bigger issue for Federer in such touch-and-go situations, he said, is how to play them — like a kid who has more talent and guts than brains, or a veteran whose prudence leaves him open to a bold and predatory opponent?

“You have to be careful not to play too conservative when it matters, because you’ve seen too many times what can happen if you don’t,” he said. “But when you have a young mind, you just go for it sometimes. That’s when great things happen, when you play committed tennis. For me, it’s always a balance; play the percentages, yet play free and young in the mind.”

The formula has been working. So much so that Federer is hands down the youngest 35-year-old tennis player on the planet.