code: def update(self, result, spec):
          
          if isinstance(spec, dict):
              if spec:
                  spec_value = next(iter(spec.values()))
                  for key, value in result.items():
                      result[key] = self.update(value, spec_value)
          if isinstance(spec, list):
              if spec:
                  for i, value in enumerate(result):
                      result[i] = self.update(value, spec[0])
          if isinstance(spec, tuple):
              return tuple(self.update(value, s)
                           for s, value in zip(spec, result))
          if callable(spec):
              return spec(result)
          return result
docs: Replace elements with results of calling callables.