Properly group check for branch in zuul functions

Not every zuul changeish has a branch. As a result we must check that
the object has a branch attribute before accessing it. The code
previously attempted to do this but due to precedence rules the binding
of the check was wrong and insufficient. Fix this with liberal use of
()s to make the precedence explicit and correct.

Change-Id: I06b3fd7ec4e5bdd14af3bc0bb1f7da39e238a879