generic quad tree implementation in c++