Degenerate ring transformations in heterocyclic systems