2.5.xfix count menu children

Fixes this error in the 2.5.x branch as well.