Dynamic Bi-Directional Hierarchy Traversal (Ancestors & Descendants) Using a Reusable Component

Hi Pega Community,

We are working on a requirement that involves a dynamic, multi-level parent-child hierarchy (e.g., Level A → B → C → D).

Depending on the context of the node we currently reside in, our logic needs to be flexible enough to handle bi-directional traversal dynamically:

  • Traverse Upwards (Ancestors): If we are at Child D, retrieve all parent and grandparent details (C, B, A).

  • Traverse Downwards (Descendants): If we are at Child C, retrieve all parent details (B, A) and its child details (D).

Our Goal:

We want to encapsulate this logic into a single, reusable Data Transform (or a clean, reusable design pattern) so it works for any arbitrary depth of the hierarchy without hardcoding levels.

Questions for the Community:

  1. Is a Data Transform the right tool for handling recursive, multi-level tree traversal in Pega, or are there limitations with loops/recursion?

  2. What is the recommended Pega design pattern to achieve this efficiently? (e.g., Should we combine a parameterized Data Page with a Lookup)

Any code snippets, guardrail considerations, or architectural recommendations would be greatly appreciated.

Thank you,

Ramana.D