I tried that, but the Shah didn't abdicate without a fight, even though he was in a war himself with the Turkestan guys and the Cumans as their allies, invading Khiva when I tried pressing. It turned into a three-way war, which I won with my event troops and was helped by Zoroastrian peasants rising up and claiming two counties as well.
After that, the Cumans decided it would be fun to invade Turkestan. I swooped in and took it from under their noses. Meanwhile, I had forced the former Shah of Khiva to turn Zoroastrian. After that, I could get the two rebel counties to swear fealty (they still had their event troops, one still does to this day) and unite Khiva.
After that I simply started holy warring to the south. The Saffarids had taken over Persia entirely, but I managed to beat them while they were caught up in some other war. When I already controlled nearly 51% of Persia, they eventually they got invaded by the Caliph, who had been taking over Asia Minor, but revolted nearly directly afterwards, so I could take them. The Saffarids are now the rebellious dukes of Azerbajan.
The Caliph tried invading Persia after that several times, but because I had placed priests in nearly every county and had Church taxes at max, I had enough money for enough mercenaries, who, combined with my cultural retinues and mountain terrain, were more than enough to keep off the numerically superiour force when I was still weaker.
The Seljuks invaded at some point, but I managed to drive them off fairly easily when they split up their troops, and the Cumans to the north have been eternally wracked by rebellions and wars.
I suppose it does come down to luck a lot, but it also comes down a lot to tactical planning. In most wars I fought, losing a single important battle due to error would mean losing the entire war, and all defensive wars were over entire kingdoms. I don't know if I would have recovered from that.