I think it would be better to raise an Exception if branches is empty instead of returning without doing anything and leaving the user puzzled. @ndawe What do you think?