What would have been needed was an even quicker and more devastating defeat of Austria in 1866. Wilhelm I wanted to savour the moment and march into Vienna - however, Bismarck enticed him away from prolonging the war even further, as he feared French and possibly Russian intervention in that case. Had the Prussian advance been even faster than in OTL, and had they been able to capture Vienna -forcing Franz Joseph I fleeing to Hungary-, it could have led to an Austrian surrender. In the following peace treaty, the German part of the Austrian Empire (Deutschösterreich, Bohemia, Moravia, Krain, Littoral, etc.) might have had been ceded to Prussia, while Franz Joseph I would stay in power as the King (or even Kaiser?) of the Hungarian parts of the Austrian Empire; which would thus have ceased to exist, only to be replaced by a 'Kingdom of Hungary'/'Hungarian Empire'.
However, the French would have reacted extremely negative to this sudden rise in Prussian power, and the OTL war of 1870/1871 might have come much earlier in this case - and then maybe with Russian assistance.