The ultimate combination is a Shadow Dragon Great Wyrm with one extra level of sorcerer (to gain access to 9th level spells - specifically Mordenkainen's Disjunction and Wish) and the Quicken Breath, the Clinging Breath and the Lingering Breath feats. Of course, this leaves plenty of other useful feats available for the dragon such Combat Reflexes (depending on the dexterity it rolls + the 5 inherent points it inevitably grants itself with the wish spell), Large and in Charge and Quicken Spell.
Sample combat against a standard (1 fighter, 1 wizard, 1 rogue, 1 cleric) 20th level party (the dragon above is CR 25 - so it should be a very tough 'boss' fight, but not an impossible one):
Initiative:
Let's be generous and say that the party wins the initiative, but nobody is surprised or flat-footed.
Party's Turn on Round 1:
- Attack the dragon with spells, ranged weapons and melee weapons. Dragon gets AOOs against all who try to melee with it (due to combat reflexes) and with the large and in charge feat almost certainly ensures that they fail to close in and waste their turn + get damaged.
Dragon's Turn on Round 1:
- Cast Mordenkainen's disjunction to dispell any protections, disable magic items and disjoin other spells the party may have cast.
- As a free action use the breath weapon against the greatest concentration of the party members, but ascribing particular importance to the cleric and almost no importance to the rogue. These party members automatically lose 8 levels (save for half, but really high save required [I think it is 39]).
Party's Turn on Round 2:
Run away after loosing so many levels in one round!
Ok, ok, so the party now has several options. Those caugh in the area of effect of the breath must make a decision. They can keep on attacking the dragon or doing whatever they were doing previously, but this means they loose another 8 levels (save for half, but save almost impossibly high) for a total of 16 levels lost in 2 rounds! This would bring them down from level 20 to level 4!! Alternatively, they can spend the round to move out of the area of effect and loose only 4 levels (save for half...) [from the clinging breath] for a total of 12 levels lost. Another option is to roll on the ground or take other actions to get rid of the clinging breath, but therefore be forced to remain in the area of the lingering breath and again loose 4 levels (save for half). Whatever their action, at the very least their cleric is now useless and other party members are also useless if they were caught in the area of effect of the breath (I am betting at least one other character would be caught).
Those who were not caught in the area of effect keep on attacking the dragon or perhaps begin a withdrawal. Again, however, the dragon's combat reflexes and large and in charge feats make approaching the dragon for melee very difficult, so they are probably relegated to less damaging ranged weapons.
Dragon's Turn on Round 2:
The dragon is now probably quite damaged, but the party's state is nothing short of disastrous. The dragon can cast one 5th level or lower quickened spell as well as full attack the remanants of the party.
Combat over!
Yes, this is very simplified - I think it would actually be much worse in many other situations - especially out in the open - ouch!