Hi Anuj,
What is your collective order structure ? I mean, how deep it is ?
You could always build logic to find which order is subordinate by checking if it has a leading order indicator as empty, if empty it is a leading order if not empty it is subordinate of the leading order.
Hope this helps.
Best Regards,
Ameya B.