Ontologies: test parent class only for first element of path

Testing the parent class on all elements of the feature doesn't work.
The test is pretty naive and assumes too much about the structure of the
graph.
Improve performance of some aggregation queries

Replacing count(column) with count(*) in SQL queries can lead to a
performance improvement (e.g. queries like retrieving the number of
treenodes per skeleton).  This, however, only works correctly if the
column of interest has a NOT NULL constraint. Without it, count(column)
and count(*) would have different semantics. The former wouldn't include
NULL in the given column. The latter in turn would.