Minor code improvement

Reduce if- else on function countMenuChildren()