implement duplicate branch checking