code: def translate(value):
      if isinstance(value, BaseValidator):
          return value
      if value is None:
          return Anything()
      if isinstance(value, type):
          return IsA(value)
      if type(value) in compat.func_types:
          real_value = value()
          return IsA(type(real_value), default=real_value)
      if isinstance(value, list):
          if value == []:
              return IsA(list)
          elif len(value) == 1:
              return ListOf(translate(value[0]))
          else:
              raise StructureSpecificationError(
                  'Expected a list containing exactly 1 item; '
                  'got {cnt}: {spec}'.format(cnt=len(value), spec=value))
      if isinstance(value, dict):
          if not value:
              return IsA(dict)
          items = []
          for k, v in value.items():
              if isinstance(k, BaseValidator):
                  k_validator = k
              else:
                  k_validator = translate(k)
                  default = k_validator.get_default_for(None)
                  if default is not None:
                      k_validator = Equals(default)
              v_validator = translate(v)
              items.append((k_validator, v_validator))
          return DictOf(items)
      return IsA(type(value), default=value)