Edit; my example wasn't for binary tree's, so I re-wrote the example.
You want to write a function that defines the recursive traversal, then invoke that function within another method. Below is a minimalistic representation of what I'm talking about, to help you understand what I mean;
Code:
int traverse(node *n, int depth)
{
depth++;
if (n->right != NULL) { traverse(n->right, depth); }
if (n->left != NULL) { traverse(n->left, depth); }
return 1;
}
void crawl_binarytree()
{
// initiate stuff here, then pass to params + initiate recursive traversal
int res = traverse(rootnode, 0);
}
When I write software to do this kind of stuff I'll design a class where I implement the traversal in private and then create a public method which actually calls the traversal and manages/returns results of the traversal.