simplified tree.c