This is a very common problem. Look at the following code block:
if(trav->children[i] != NULL)
trav = trav->children[i];
The code is recursively calling erase, but the problem is what happens on the return path. Let's trace what happens for a bit. Say that you are a few levels into the recursion. We'll call it level 3. Now, the child is not null, so the next two lines execute. trav, which was at level 3 is now assigned to its child, a member of level 4. erase is then called on level 4. For now, we can ignore any further recursions and look at what happens when the code comes back from this call. trav, which was trying to process level 3 elements is now set to level 4 as the code goes back and starts the next pass of the for loop. This means that the rest of level 3 is lost.
To fix this, don't assign the value of the child to trav. Instead, call erase using trav->children.
Next, there's the bigger issue of the free statement. It's inside the for loop. How many times are you going to free it, and what happens if you free it before completing the for loop?
If this answers your question, please click on the check mark to accept. Let's keep up on forum maintenance. ;-)