try to make the memory management thread save by using a mutex upon tree accesses