implemented the counting function in the ADTree - didn't test it yet, it
compiles.