Switch interactions control energy frustration and multiple flagellar filament structures.