bisect: implement the "check_merge_bases" function