method to give unique ids to branches
method to give unique ids to branches