The highest we ever took Pathfinder 1e was 17th level in Kingmaker. The worst encounters were always those against NPCs because the default builds for NPCs never equipped them properly (and were often poorly optimized). The last fight was pretty good though. By the end, over half the party was dead or in another dimension, and the PC with Briar was down to low (or maybe even single digit) hit points. I also liked the medusa fight because the PCs put on blindfolds and tried to use sound to locate the medusa (only the wizard got petrified while peeking).
Thinking back on it now, the best fights towards the end were those where death was on a table. It was practically just another status effect for us. We had 20+ deaths over the course of that campaign, and most of them were in the higher levels (at least a quarter being in the final dungeon). I wonder how much the perception that it’s hard to create challenging fights correlates with how willing the GM is to kill PCs.