recursive grade calculation of units