TMDM-7354: "use studio export content from mdm server ,need reordering the statements"

Fix incorrect order for LENIENT sort.
Fix including twice types in breakable cycles.
Fix including multiple times types when cycle intersection isn't empty.
Add unit test for reproducing issue.
Merge branch 'bugfix/5.6/TMDM-7354'