Records are being saved as parent-child in the same table linked with pairkey column and then even parents are divided into two legs linked with scndleg column. That is, there will be two parent legs interlinked with scndleg column and each parent will have children having seqnno of parent in pairkey column.
Look at this fiddle
I need to select one complete batch as
Both legs of interlinked parents
UNION
All children of these two parents
and then the other batch following same pattern and so on shown in the fiddle