code: def _encode_optimized(item):
      
      if isinstance(item, bytes):
          if len(item) == 1 and ord(item) < 128:
              return item
          prefix = length_prefix(len(item), 128)
      else:
          item = b''.join([_encode_optimized(x) for x in item])
          prefix = length_prefix(len(item), 192)
      return prefix + item
docs: RLP encode (a nested sequence of) bytes