Locking system for nodes in a binary tree