def _VisitHelper(self, node, handler):
    if isinstance(node, dict):
      for key, value in node.items():
        # Recursively visit the dictionary contents.
        self._VisitHelper(value, handler)

        # Give handler a chance to modify the (key, value) pair.
        result = handler(key, value)
        if result is None:
          # None, so do nothing to this field.
          continue

        # Remove the field
        del node[key]

        # Add new field if one was returned.
        if len(result) == 2:
          node[result[0]] = result[1]
    elif isinstance(node, list):
      # Recursively visit list contents.
      for item in node:
        self._VisitHelper(item, handler)
Helper visitor that traverses the message tree.
dataset/ETHPy150Open viewfinderco/viewfinder/backend/base/message.py/Message._VisitHelper