Some explanatory comments would help.
We could read through the code and try and decipher and or guess what you are doing but that would take unnecessary time. So, explanatory comments please!
Regards
Sorry.
I am navigating through a tree structure.
Each "hold" item is a different level on the tree.
I start by feeding the query the serial number of the product I am looking for, then query for all of the parent groups that have this product in it. The product can have multiple parents.
I then go up another level to get the parents of those groups which each only have a single parent.
What I am ultimately trying to do is trace the product to each of it's root level ancestors and tracking all of the ancestors along the way.
Example:
If I have product 2227, it's immediate parents may be:
ABC_account
ABC_sales_account
XZY_Products
Then the final results would be like this.
Customer_accounts/USA_accounts/ABC_account/2227
Sales_accoucts/USA_Sales/ABC_sales_account/2227
Product_portfolio/USA_Products/XYZ_products/22y