The implemented solution retrieves the full organizational hierarchy using a recursive depth-first traversal approach.
The logic is based on a function that accepts:
- A parent organization ID
- A collection used to accumulate child nodes
The function performs the following steps:
- It retrieves all direct child organizations for the given parent.
- Each child is added to the output collection.
- For every child, the same function is called recursively, passing:
- The child as the new parent
- The updated collection of results
- This process continues until all levels of the hierarchy are explored.
This approach ensures that:
- The hierarchy is traversed depth-first
- All descendants of a node are retrieved before moving to the next sibling
- The final output contains the complete organizational tree under the initial parent

recursion function outsystems 1.png