Frederick the Iron on Polish throne appeared in TLs before as secondary POD (used for example by @The Undead Martyr in his Visconti TL) so that is not very original idea. Although I'm going to focus on Frederick's succession in Poland as main POD here.
So change is not very complicated-Jogaila's fourth wife has no kids with him, it became clear after few years that King would not have a son, thus his daughter from second marriage with Anna of Cili remains his heiress.
Jogaila's daughter Hedwig was born in 1408, through her mother she was great-granddaughter of Casimir the Great. In 1413 she was proclaimed heiress of the Kingdom in Jedlnia. She was betrothed to Frederick, later called the Iron, second son of Elector of Brandenburg Frederick I Hohenzollern. Young Frederick was send to Poland to learn language and customs of the Kingdom he was planned to rule as husband of Hedwig. Things changes were Hedwig's half brothers were born and Jogaila had to disinherit his daughter (which wasn't easy, because they were born from wrong mother) his struggle was partially successfull-he secured throne for his male heir, but unlike Hedwig, his sons were denied hereditary rights to the Polish throne. Something like this would not happen ITTL. Jogaila's daughter is proclaimed heiress already, with stronger rights to the throne than his OTL sons. Thus Frederick's succession in Poland would be less problematic than that of Vladislaus III IOTL (especially taking into account his age-he was 11 years older than Vladislaus III was). @krieget Lithuania-that is another story. Unlike Poland Lithuania lacks tradition of female succession and there are plenty of male Gediminids around. Vytautas accepted Frederick as heir of Lithuania as well and Frederick was for a while under his custody in Vilnius. Thus after Vytautas' death Jogaila would want his son-in-law to succeede Vytautas as next Grand Duke. IOTL Jogaila attempted to retake personal rule in Lithuania after death of Vytautas and his attempt inflicted rebellion of Švitrigaila and civil war in Lithuania. Frederick is not the same person as Jogaila, so if he is installed in Vilnius Lithuania would still have separate Grand Duke, but:
-Frederick is Jogaila's obvious heir in Poland
-he is not Gediminid
So there would still be a war with Švitrigaila and his supporters, question is: would it start immediately after death of Vytautas or would it happen after death of Jogaila, after Frederick takes Polish Crown and leave Vilnius for Cracow? @Augenis ?
Would Polish-Lithuanian union survive in such circumstances?
Brandenburg is another question. Frederick I had enough sons to appoint another one as successor of his Electoral title, Frederick IOTL was selected by father despite not being oldest, so nothing impossible about this.
So change is not very complicated-Jogaila's fourth wife has no kids with him, it became clear after few years that King would not have a son, thus his daughter from second marriage with Anna of Cili remains his heiress.
Jogaila's daughter Hedwig was born in 1408, through her mother she was great-granddaughter of Casimir the Great. In 1413 she was proclaimed heiress of the Kingdom in Jedlnia. She was betrothed to Frederick, later called the Iron, second son of Elector of Brandenburg Frederick I Hohenzollern. Young Frederick was send to Poland to learn language and customs of the Kingdom he was planned to rule as husband of Hedwig. Things changes were Hedwig's half brothers were born and Jogaila had to disinherit his daughter (which wasn't easy, because they were born from wrong mother) his struggle was partially successfull-he secured throne for his male heir, but unlike Hedwig, his sons were denied hereditary rights to the Polish throne. Something like this would not happen ITTL. Jogaila's daughter is proclaimed heiress already, with stronger rights to the throne than his OTL sons. Thus Frederick's succession in Poland would be less problematic than that of Vladislaus III IOTL (especially taking into account his age-he was 11 years older than Vladislaus III was). @krieget Lithuania-that is another story. Unlike Poland Lithuania lacks tradition of female succession and there are plenty of male Gediminids around. Vytautas accepted Frederick as heir of Lithuania as well and Frederick was for a while under his custody in Vilnius. Thus after Vytautas' death Jogaila would want his son-in-law to succeede Vytautas as next Grand Duke. IOTL Jogaila attempted to retake personal rule in Lithuania after death of Vytautas and his attempt inflicted rebellion of Švitrigaila and civil war in Lithuania. Frederick is not the same person as Jogaila, so if he is installed in Vilnius Lithuania would still have separate Grand Duke, but:
-Frederick is Jogaila's obvious heir in Poland
-he is not Gediminid
So there would still be a war with Švitrigaila and his supporters, question is: would it start immediately after death of Vytautas or would it happen after death of Jogaila, after Frederick takes Polish Crown and leave Vilnius for Cracow? @Augenis ?
Would Polish-Lithuanian union survive in such circumstances?
Brandenburg is another question. Frederick I had enough sons to appoint another one as successor of his Electoral title, Frederick IOTL was selected by father despite not being oldest, so nothing impossible about this.