code: def _traverse(element, condition=None):
          
          if condition is None or condition(element):
              yield element
          if isinstance(element, DictElement):
              for child in element.values():
                  for _ in BaseElement._traverse(child, condition):
                      yield _
          elif isinstance(element, ListElement):
              for child in element:
                  for _ in BaseElement._traverse(child, condition):
                      yield _
          elif attr.has(element.__class__):
              for field in attr.fields(element.__class__):
                  child = getattr(element, field.name)
                  for _ in BaseElement._traverse(child, condition):
                      yield _
docs: Traversal API intended for debugging.