docs: def write(self):
          """Write object state to Zookeeper.
  
          This will write the current state of the object to Zookeeper,
          taking the final merged state as the new one, and resetting
          any write buffers.
          """
          self._check()
          cache = self._cache
          pristine_cache = self._pristine_cache
          self._pristine_cache = cache.copy()
  
          # Used by `apply_changes` function to return the changes to
          # this scope.
          changes = []
  
          def apply_changes(content, stat):
              """Apply the local state to the Zookeeper node state."""
              del changes[:]
              current = yaml.load(content) if content else {}
              missing = object()
              for key in set(pristine_cache).union(cache):
                  old_value = pristine_cache.get(key, missing)
                  new_value = cache.get(key, missing)
                  if old_value != new_value:
                      if new_value != missing:
                          current[key] = new_value
                          if old_value != missing:
                              changes.append(
                                  ModifiedItem(key, old_value, new_value))
                          else:
                              changes.append(AddedItem(key, new_value))
                      elif key in current:
                          del current[key]
                          changes.append(DeletedItem(key, old_value))
              return yaml.safe_dump(current)
  
          # Apply the change till it takes.
          yield retry_change(self._client, self._path, apply_changes)
          returnValue(changes)