def METHOD_NAME(branch, success_flag="succeeded"):
    """find latest successful build id for a branch"""
    builds_url = "https://dev.azure.com/mssonic/build/_apis/build/builds?definitions=1&branchName=refs/heads/{}" \
                 "&resultFilter={}&statusFilter=completed&api-version=6.0".format(
                     branch, success_flag)
    resp = urlopen(builds_url)
    j = json.loads(resp.read().decode('utf-8'))
    value = j.get('value', [])
    if len(value) > 0:
        latest_build_id = int(value[0]['id'])
    else:
        latest_build_id = NOT_FOUND_BUILD_ID
    return latest_build_id