<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _remove_document(self, gh_user, doc_id, parent_sha, author, commit_msg=None):
 """Remove a document Remove a document on the given branch and attribute the commit to author. Returns the SHA of the commit on branch. """

        # _LOG.debug("@@@@@@@@ GitActionBase._remove_document, doc_id={}".format(doc_id))
        doc_filepath = self.path_for_doc(doc_id)
        # _LOG.debug("@@@@@@@@ GitActionBase._remove_document, doc_filepath={}".format(doc_filepath))

        branch = self.create_or_checkout_branch(gh_user, doc_id, parent_sha)
        prev_file_sha = None
        if commit_msg is None:
            msg = "Delete document '%s' via OpenTree API" % doc_id
        else:
            msg = commit_msg
        if os.path.exists(doc_filepath):
            prev_file_sha = self.get_blob_sha_for_file(doc_filepath)
            if self.doc_type == 'nexson':
                # delete the parent directory entirely
                doc_dir = os.path.split(doc_filepath)[0]
                # _LOG.debug("@@@@@@@@ GitActionBase._remove_document, doc_dir={}".format(doc_dir))
                git(self.gitdir, self.gitwd, "rm", "-rf", doc_dir)
            elif self.doc_type in ('collection', 'favorites', 'amendment'):
                # delete just the target file
                git(self.gitdir, self.gitwd, "rm", doc_filepath)
            else:
                raise NotImplementedError("No deletion rules for doc_type '{}'".format(self.doc_type))
            git(self.gitdir,
                self.gitwd,
                "commit",
                author=author,
                message=msg)
        new_sha = git(self.gitdir, self.gitwd, "rev-parse", "HEAD").strip()
        return {'commit_sha': new_sha,
                'branch': branch,
                'prev_file_sha': prev_file_sha,
                }