Code refactor for get branch by ID function

Migrated issue

Reported by: jhodgdon

There are a lot of places in the code where something like this is done:
$branches = api_get_branches();
$branch = $branches[$function->branch_id];

It seems like it would make sense to make this into its own function, perhaps? Maybe not, as it's only two lines...

Actually, we could add $branch_id as a 2nd argument to api_get_branches() and do it there?