docs: def make_tree(file):
      """Create tree structure from ZIP archive."""
      max_files_count = current_app.config.get('PREVIEWER_ZIP_MAX_FILES', 1000)
      tree = {'type': 'folder', 'id': -1, 'children': {}}
  
      try:
          with file.open() as fp:
              zf = zipfile.ZipFile(fp)
              # Detect filenames encoding.
              sample = ' '.join(zf.namelist()[:max_files_count])
              if not isinstance(sample, binary_type):
                  sample = sample.encode('utf-16be')
              encoding = chardet.detect(sample).get('encoding', 'utf-8')
              for i, info in enumerate(zf.infolist()):
                  if i > max_files_count:
                      raise BufferError('Too many files inside the ZIP file.')
                  comps = info.filename.split(os.sep)
                  node = tree
                  for c in comps:
                      if not isinstance(c, text_type):
                          c = c.decode(encoding)
                      if c not in node['children']:
                          if c == '':
                              node['type'] = 'folder'
                              continue
                          node['children'][c] = {
                              'name': c,
                              'type': 'item',
                              'id': 'item{0}'.format(i),
                              'children': {}
                          }
                      node = node['children'][c]
                  node['size'] = info.file_size
      except BufferError:
          return tree, True, None
      except (zipfile.LargeZipFile):
          return tree, False, 'Zipfile is too large to be previewed.'
      except Exception as e:
          current_app.logger.warning(str(e), exc_info=True)
          return tree, False, 'Zipfile is not previewable.'
  
      return tree, False, None