code: def export_tree(lookup, tree, path):
      
      FILE_PERM = S_IRWXU | S_IRWXG | S_IRWXO
  
      for name, mode, hexsha in tree.iteritems():
          dest = os.path.join(path, name)
  
          if S_ISGITLINK(mode):
              log.error('Ignored submodule {}; submodules are not yet supported.'
                        .format(name))
              # raise ValueError('Does not support submodules')
          elif S_ISDIR(mode):
              os.mkdir(dest)
              os.chmod(dest, 0o0755)
              export_tree(lookup, lookup(hexsha), dest)
          elif S_ISLNK(mode):
              os.symlink(lookup(hexsha).data, dest)
          elif S_ISREG(mode):
              with open(dest, 'wb') as out:
                  for chunk in lookup(hexsha).chunked:
                      out.write(chunk)
              os.chmod(dest, mode & FILE_PERM)
          else:
              raise ValueError('Cannot deal with mode of {:o} from {}'.format(
                  mode, name))
docs: Exports the given tree object to path.
  
      :param lookup: Function to retrieve objects for SHA1 hashes.
      :param tree: Tree to export.
      :param path: Output path.