Add branch_exists? function

Change-Id: I61420341f0363186bbab4b4457a1d50d31eec00e