Heroes and/or traitors
Rulers of medieval Wales tend to be divided into two categories: national heroes or backstabbing traitors. Sometimes these traits are combined in one person: Dafydd ap Gruffudd for instance, who treacherously served Edward I for 19 years before heroically being executed. These medieval figures are made to serve our needs, not theirs. That is the wrong way round (imo).
My own take is that these Welsh rulers were equally hostile towards invaders from east of Offa's Dyke – Saxons, Normans, Anglo-Normans etc – as they were to local rivals. Their chief concern was to safeguard their lineage and protect and extend their territory.
King Madog ap Maredudd, last ruler of a united kingdom of Powys, is one example. Madog succeeded to the kingdom on his father's death in 1132, and would rule until 1160. During his reign Powys emerged as one of the most powerful realms in Wales, under a single dynasty, only to collapse into division after his death.
Madog was every bit as impressive as his better-known contemporaries, Owain Gwynedd and Rhys ap Gruffudd of Deheubarth. He was celebrated in poetry and prose tales such as 'Breudwyt Ronawby', which proclaimed him the ruler of Powys 'from end to end' i.e. from the border of Chester to the boundary between Powys and Ceredigion.
In his early career, Madog bolstered his power by alliance with Ranulf, earl of Chester: he was one of two Welsh rulers who fought beside the earl at the battle of Lincoln in 1141. The alliance failed when Ranulf was imprisoned by King Stephen in 1146.
Owain Gwynedd exploited Ranulf's ill-fortune by destroying the castle of Mold, an outpost of the earldom of Chester next to Powys. This in turn brought Owain into conflict with Madog. After Ranulf was released from prison, he and Madog teamed up again to fight the Venedotians.
The result was the battle of Coleshill, fought in 1150. Madog and Ranulf were defeated: “King Madog ap Maredudd of Powys, with the help of Earl Ranulf of Chester, prepared to rise up against Owain Gwynedd. And after the people of his supporters had been slain at Coleshill, the rest turned their backs in flight.” (Brut y Tywysogion)
Madog's concern was to win back his lost lands in the eastern part of the Perfeddwlad. Seven years later, he fought for Henry II against Owain Gwynedd and probably advised the king to take a similar route, this time with more success.
Although defeated at Coleshill, Madog and his dynasty quickly recovered. In 1152 his son Llywelyn, hailed by poets as the great hope of Powys, slew Stephen Fitz Baldwin, a son of the Norman lord of Montgomery. This implies Madog planned to extend his power into another neighbouring region, this time held against him by the Normans. Fine, he would kill them too.