def auto_delete_pr_branch(pr: PullRequestDetails) -> bool:
    """
    References:
        https://developer.github.com/v3/git/refs/#delete-a-reference
    """

    open_pulls = list_open_pull_requests(pr.repo, base_branch=pr.branch_name)
    if any(open_pulls):
        log('Not deleting branch {!r}. It is used elsewhere.'.format(
            pr.branch_name))
        return False

    remote = pr.remote_repo
    if pr.is_on_fork():
        log('Not deleting branch {!r}. It belongs to a fork ({}/{}).'.format(
            pr.branch_name,
            pr.remote_repo.organization,
            pr.remote_repo.name))
        return False

    url = ("https://api.github.com/repos/{}/{}/git/refs/heads/{}"
           "?access_token={}".format(remote.organization,
                                     remote.name,
                                     pr.branch_name,
                                     remote.access_token))
    response = requests.delete(url)

    if response.status_code == 204:
        # Delete succeeded.
        log('Deleted branch {!r}.'.format(pr.branch_name))
        return True

    log('Delete failed. Code: {}. Content: {}.'.format(
        response.status_code, response.content))
    return False
References:
        https://developer.github.com/v3/git/refs/#delete-a-reference