# Path: pyalgs/algorithms/commons/util.py
# def cmp(a, b):
#     if a is None:
#         return -1
#     if b is None:
#         return -1
#     return (a > b) - (a < b)
# 
# Path: pyalgs/data_structures/commons/queue.py
# class Queue(object):
#     """ Queue interface
#     
#     """
# 
#     __metaclass__ = ABCMeta
# 
#     @abstractmethod
#     def enqueue(self, item):
#         pass
# 
#     @abstractmethod
#     def dequeue(self):
#         pass
# 
#     @abstractmethod
#     def is_empty(self):
#         pass
# 
#     @abstractmethod
#     def size(self):
#         pass
# 
#     @staticmethod
#     def create():
#         return LinkedListQueue()
# 
#     @abstractmethod
#     def iterate(self):
#         pass


from abc import ABCMeta
from pyalgs.algorithms.commons.util import cmp
from pyalgs.data_structures.commons.queue import Queue

    def put(self, key, value):
        self.root = self._put(self.root, key, value)

    def _put(self, x, key, value):
        if x is None:
            return Node(key, value)

        compared = cmp(key, x.key)

        if compared < 0:
            x.left = self._put(x.left, key, value)
        elif compared > 0:
            x.right = self._put(x.right, key, value)
        else:
            x.value = value

        x.count = 1 + _count(x.left) + _count(x.right)

        return x

    def get(self, key):
        x = self._get(self.root, key)
        if x is None:
            return None
        return x.value

    def _get(self, x, key):
        if x is None:
            return None

# Path: pyalgs/algorithms/commons/util.py
# def cmp(a, b):
#     if a is None:
#         return -1
#     if b is None:
#         return -1
#     return (a > b) - (a < b)
# 
# Path: pyalgs/data_structures/commons/queue.py
# class Queue(object):
#     """ Queue interface
#     
#     """
# 
#     __metaclass__ = ABCMeta
# 
#     @abstractmethod
#     def enqueue(self, item):
#         pass
# 
#     @abstractmethod
#     def dequeue(self):
#         pass
# 
#     @abstractmethod
#     def is_empty(self):
#         pass
# 
#     @abstractmethod
#     def size(self):
#         pass
# 
#     @staticmethod
#     def create():
#         return LinkedListQueue()
# 
#     @abstractmethod
#     def iterate(self):
#         pass


# Path: pyalgs/data_structures/commons/binary_search_tree.py
from abc import ABCMeta
from pyalgs.algorithms.commons.util import cmp
from pyalgs.data_structures.commons.queue import Queue


    def put(self, key, value):
        self.root = self._put(self.root, key, value)

    def _put(self, x, key, value):
        if x is None:
            return Node(key, value)

        compared = cmp(key, x.key)

        if compared < 0:
            x.left = self._put(x.left, key, value)
        elif compared > 0:
            x.right = self._put(x.right, key, value)
        else:
            x.value = value

        x.count = 1 + _count(x.left) + _count(x.right)

        return x

    def get(self, key):
        x = self._get(self.root, key)
        if x is None:
            return None
        return x.value

    def _get(self, x, key):
        if x is None:
            return None

        compared = cmp(key, x.key)