<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def archive(self, ostream, treeish=None, prefix=None, **kwargs):
 """Archive the tree at the given revision. :param ostream: file compatible stream object to which the archive will be written as bytes :param treeish: is the treeish name/id, defaults to active branch :param prefix: is the optional prefix to prepend to each filename in the archive :param kwargs: Additional arguments passed to git-archive * Use the 'format' argument to define the kind of format. Use specialized ostreams to write any format supported by python. * You may specify the special **path** keyword, which may either be a repository-relative path to a directory or file to place into the archive, or a list or tuple of multiple paths. :raise GitCommandError: in case something went wrong :return: self"""

        if treeish is None:
            treeish = self.head.commit
        if prefix and 'prefix' not in kwargs:
            kwargs['prefix'] = prefix
        kwargs['output_stream'] = ostream
        path = kwargs.pop('path', [])
        if not isinstance(path, (tuple, list)):
            path = [path]
        # end assure paths is list

        self.git.archive(treeish, *path, **kwargs)
        return self