// aux display and verification routines, helpful but not essential
struct trunk {
	struct trunk *prev;
	char * str;
};
 
static void show_trunks(struct trunk *p)
{
	if (!p) return;
	show_trunks(p->prev);
	printf("%s", p->str);
}
 
// this is very haphazzard
static void show_tree(struct tree_node *root, struct trunk *prev, int is_left)
{
	if (root == NULL) return;

	struct trunk this_disp = { prev, "    " };
	char *prev_str = this_disp.str;
	show_tree(root->right, &this_disp, 1);

	if (!prev)
		this_disp.str = "---";
	else if (is_left) {
		this_disp.str = ".--";
		prev_str = "   |";
	} else {
		this_disp.str = "`--";
		prev->str = prev_str;
	}

	show_trunks(&this_disp);
	if ( root->key >= 'A' && root->key <= 'Z' )
		printf("%c\n", root->key);
	else
		printf("%d\n", root->key);

	if (prev) prev->str = prev_str;
	this_disp.str = "   |";

	show_tree(root->left, &this_disp, 0);
	if (!prev) puts("");
}

