#1522: Replaced recursive object graph traversing with a linear solution using a stack to avoid stack overflows.