Check if an hierarchical item has children before selecting it

We are trying to add indication arrows to hierarchical menu like this:


However it’s not possible to know if an Category has children or not until it’s selected. The Air Filters actually does not have any children, so we need to hide its arrow like this:


How can we know if the category has children or not without selecting it first?