Determining entity types in KmlDataSource

I have loaded a kml file into a KmlDataSource, and I see the hierarchy of entities corresponding to what is in the file. I now need to know which node type each of the entities is so I can treat them appropriately in my application (for example, Folder, Placemark, or MultiGeometry). How can I find out which type each entity is?