Run your java code again but without the count function. You'll get back a list of nodes (sometimes elements and sometime attributes). Iterate over the list and write out the name of each node. That will help you understand which of the nodes are included in each of the counts.