Depth first tree traversal in C