Index: suite_leahi/shared/scripts/configuration/utility.py =================================================================== diff -u -rf6d23e89ccf01b57313b0e920f013dc1027706d4 -rce164b0ef964275d2d15799391c031c4073e8d07 --- suite_leahi/shared/scripts/configuration/utility.py (.../utility.py) (revision f6d23e89ccf01b57313b0e920f013dc1027706d4) +++ suite_leahi/shared/scripts/configuration/utility.py (.../utility.py) (revision ce164b0ef964275d2d15799391c031c4073e8d07) @@ -40,3 +40,36 @@ found = findChildByText(child, target_text) if found: return found + +def findAllObjectsById(parent, target_id): + """ + Recursively finds all child objects by their id property. + Returns a list of all matching objects found. + """ + results = [] + + # Use hasattr to safely check for 'id' property + if hasattr(parent, 'id') and str(parent.id) == target_id: + results.append(parent) + + # Recurse through all children to collect all instances + for child in object.children(parent): + results.extend(findAllObjectsById(child, target_id)) + + return results + +def findAllObjectsByText(parent, target_text): + """ + Recursively finds all child objects that have a 'text' property + matching the target_text. Returns a list of matches. + """ + results = [] + # Use hasattr to safely check for 'text' property before comparing + if hasattr(parent, 'text') and str(parent.text) == target_text: + results.append(parent) + + # Recurse through all children + for child in object.children(parent): + results.extend(findAllObjectsByText(child, target_text)) + + return results