Refactored Red-black tree to work with stack.