When the search tree has no elements, it seems the CNearTreeObjects
function does not give a CVector with zero elements but rather a
null pointer. This results in a null dereference when that is
passed to CVectorSize, instead of 0 as expected.
Add an explicit check for this case to avoid crashing.