fix bug in LockTree::release
extract generic tree impl into Node.py