Imported from https://github.com/agongt408/vbranch