public void lock() {
            if(numChildreLocks_ == 0 && !locked_) {
                // Make sure all parents do not lock.
                BinaryTree<T> n = parent_;
                while(n != null) {
                    if(n.locked_) {
                        return;
                    }
                    n = n.parent_;
                }

                // Lock itself and update its parents.
                locked_ = true;
                n = parent_;
                while(n != null) {
                    ++n.numChildreLocks_;
                    n = n.parent_;
                }
            }
        }