function for calculating max number of branches under a node