So, let's say your feudal overlord is rebelling against the king. Who do you owe your allegiance to, the lord, or the king? It's best to fight for the one who's going to win, obviously, but what would the lawful decision be?
In practice, throughout most of Western Europe, the nobility rapidly descended into just that subset of tenants who owed allegiance directly to the monarch - the tenants-in-chief.
Likewise, only those tenants-in-chief were generally liable for treason - those below the nobility being both too valuable and too numerous to hold accountable for the acts of their liege-lords. Provided they subsequently swore fealty to whomever the monarch replaced their treasonous former lord with, all was in general forgiven.
The primary exception to this was in the Holy Roman Empire, where the original stem duchies splintered into far more numerous imperial princes holding Landhoheit - sovereignty - within their own territory and entitled to inter-marry with reigning dynasties.