def close_stale_prs(self, update, pull_request, scheduled):
        """
        Closes stale pull requests for the given update, links to the new pull request and deletes
        the stale branch.
        A stale PR is a PR that:
         - Is not merged
         - Is not closed
         - Has no commits (except the bot commit)
        :param update:
        :param pull_request:
        """
        closed = []
        if self.bot_token and not pull_request.is_initial:
            for pr in self.pull_requests:
                close_pr = False
                same_title = \
                    pr.canonical_title(self.config.pr_prefix) == \
                    pull_request.canonical_title(self.config.pr_prefix)

                if scheduled and pull_request.is_scheduled:
                    # check that the PR is open and the title does not match
                    if pr.is_open and not same_title:
                        # we want to close the previous scheduled PR if it is not merged yet
                        # and we want to close all previous updates if the user choose to
                        # switch to a scheduled update
                        if pr.is_scheduled or pr.is_update:
                            close_pr = True
                elif pull_request.is_update:
                    # check that, the pr is an update, is open, the titles are not equal and that
                    # the requirement matches
                    if pr.is_update and \
                        pr.is_open and \
                            not same_title and \
                            pr.get_requirement(self.config.pr_prefix) == update.requirement.key:
                        # there's a possible race condition where multiple updates with more than
                        # one target version conflict with each other (closing each others PRs).
                        # Check that's not the case here
                        if not self.has_conflicting_update(update):
                            close_pr = True

                if close_pr and self.is_bot_the_only_committer(pr=pr):
                    logger.info("Closing stale PR {} for {}".format(pr.title, pull_request.title))
                    self.provider.close_pull_request(
                        bot_repo=self.bot_repo,
                        user_repo=self.user_repo,
                        pull_request=pr,
                        comment="Closing this in favor of #{}".format(
                            pull_request.number),
                        prefix=self.config.branch_prefix
                    )
                    pr.state = "closed"
                    closed.append(pr)
        for closed_pr in closed:
            self.pull_requests.remove(closed_pr)
Closes stale pull requests for the given update, links to the new pull request and deletes
        the stale branch.
        A stale PR is a PR that:
         - Is not merged
         - Is not closed
         - Has no commits (except the bot commit)
        :param update:
        :param pull_request: