implement locking in a binary tree