def process_user_command(game_tree, target_tree, curr, pic):
    '''Read and process one command from the user, modifying BTNode game_tree
    and current BTNode curr as appropriate and redrawing the new game_tree and
    BTNode target_tree on Picture pic.  Return the new value of curr.'''

    d = {'Left': 'l', 'Right': 'r', 'Up': 'u', 'a': 'L', 's': 'R', 'q': 'q'}
    cmd = d.get(KD.moving_by_keys().key, 'm')

    # Only listen to valid commands.
    if len(cmd) != 1 or cmd[0] not in 'qulrLR':
        return curr

    # Erase the old tree and redraw target_tree halfway across the window.
    media.add_rect_filled(pic, 0, 0, WIDTH, HEIGHT, media.white)
    draw(pic, target_tree.root, 0, WIDTH / 2, curr)

    # Process user commands.
    if cmd == 'q':
        media.close(pic)
        sys.exit(0)
    elif cmd == 'u' and curr != None and curr.parent != None:
        curr = curr.parent
    elif cmd == 'l' and curr.left != None:
        curr = curr.left
    elif cmd == 'r' and curr.right != None:
        curr = curr.right
    elif cmd == 'L' and curr.right != None:
        curr = bst.rotate_left(game_tree, curr)
    elif cmd == 'R' and curr.left != None:
        curr = bst.rotate_right(game_tree, curr)

    # The parent attribute of the nodes of the new tree must be corrected.
    # If curr is at the top, a rotation may have moved it there. Set the
    # game_tree root to curr if that happened.

    if curr.parent == None:
        game_tree.root = curr

    # Draw the new game tree.
    draw(pic, game_tree.root, 0, 0, curr)
    media.update(pic)

    return curr
    Rotate Clockwise, q quit.
    When the level has been solved, push y to contine and n to quit.'''
    scoring.print_highscore_list(highscore.score_list)
    raw_input("enter a key to begin: ")

    tree_size = 2
    cont = 'y'
    while cont == 'y':
        start = time.time()
        play_game(tree_size)
        end = time.time() - start
        highscore.enter_score(end)
        if tree_size < 8:
            print ("Congrats!  You finished tree size " + \
            str(tree_size) + ".  Continue (y/n)? ")
            cont = KD.moving_by_keys().key
            while cont != 'y' and cont != 'n':
                cont = KD.moving_by_keys().key
            #clear()
        else:
            #clear()
            print '''Congrats! You finished level 8 and have completed the game
            and scored a vlue of %i.''' % (int(highscore.score))
            highscore.insert_score([int(highscore.score), name])
            highscore.write_to_file()
            cont = 'n'
        tree_size += 1
    scoring.print_highscore_list(highscore.score_list)
    raw_input("Press enter to exit.")
    media.close(pic)