Treegrid row count

I have a treegrid initially filled with 5 rows in level 0. Each row has children in X levels.  mygrid.haschildren() function can be used to know the number of children of any row, but I need to know the number of rows in level 0. Is there a function that return this value??

Unfortunately current version doesn’t support such functionality. The only way to calculate it - itterate through all rows

var count=0;
grid.forEachRow(function(id){
    if (!grid.getParentId(id)) count++;
});