# Path: pigeon/xerblin/btree.py
# def get(node, key):
#     '''
#     Return the value stored under key or raise KeyError if not found.
#     '''
#     if not node:
#         raise KeyError, key
# 
#     node_key, value, lower, higher = node
# 
#     if key == node_key:
#         return value
# 
#     return get(lower if key < node_key else higher, key)
# 
# Path: pigeon/xerblin/stack.py
# def push(stack, *items):
#     '''Push arguments onto a stack.'''
#     for item in items:
#         stack = item, stack # push
#     return stack


from pigeon.xerblin.btree import get
from pigeon.xerblin.stack import push
    return I


def handle_branch(I, branch):
    '''
    Check TOS and do one thing or another depending.
    '''
    TOS, I = _pop_TOS(I)
    func = branch[(not TOS) + 1] # i.e. True = 1; False = 2
    return apply_func(I, func)


def handle_loop(I, loop):
    '''
    Check TOS and do body if it's true, repeat.
    '''
    while True:
        TOS, I = _pop_TOS(I)
        if not TOS:
            break
        I = handle_sequence(I, loop)
    return I


# This primitive permits us to create a sort of "constant" in the dictionary.

def enstacken((stack, dictionary), stack_us):
    '''
    Push the items in the body onto the stack.
    '''

# Path: pigeon/xerblin/btree.py
# def get(node, key):
#     '''
#     Return the value stored under key or raise KeyError if not found.
#     '''
#     if not node:
#         raise KeyError, key
# 
#     node_key, value, lower, higher = node
# 
#     if key == node_key:
#         return value
# 
#     return get(lower if key < node_key else higher, key)
# 
# Path: pigeon/xerblin/stack.py
# def push(stack, *items):
#     '''Push arguments onto a stack.'''
#     for item in items:
#         stack = item, stack # push
#     return stack


# Path: pigeon/xerblin/base.py
from pigeon.xerblin.btree import get
from pigeon.xerblin.stack import push

    return I


def handle_branch(I, branch):
    '''
    Check TOS and do one thing or another depending.
    '''
    TOS, I = _pop_TOS(I)
    func = branch[(not TOS) + 1] # i.e. True = 1; False = 2
    return apply_func(I, func)


def handle_loop(I, loop):
    '''
    Check TOS and do body if it's true, repeat.
    '''
    while True:
        TOS, I = _pop_TOS(I)
        if not TOS:
            break
        I = handle_sequence(I, loop)
    return I


# This primitive permits us to create a sort of "constant" in the dictionary.

def enstacken((stack, dictionary), stack_us):
    '''
    Push the items in the body onto the stack.
    '''

    stack = push(stack, *stack_us[1:])