Treegrid lazy data provider perform to many queries to Backend

Hi, I’m using a treegrid, the data provider uses lazy loading hierarchical data from back end. I’ve extended AbstractBackEndHierarchicalDataProvider and implemented hasChildren, getChildCount, fetchChildrenFromBackEnd. It is correctly working, it loads hierarchical data on-demand from the back end and the treegrid shows correctly the data when expand/collapse.

The problem is the data provider seems to perform so many queries to Backend (I’ve debugged). I mean, when expand, dataprovider invokes twice getChildCount and twice fetchChildrenFromBackEnd; when collapse, invokes once getChildCount an once fetchChildrenFromBackEnd. Why it’s necesary to carry out a query when collapse?.

Is this behavior usual? Is there any way to reduce the number of queries when collapse/expand (one query to expand and zero to collapse)?

Thanks in advance. Regards