Done. Below is the code that finally passed all of my tests. Again, this is modeled after Murilo Vasconcelo\'s modified version of Steve
As I see it right, you want to loop over all branches of the trie. That's not that difficult using a recursive function. I'm using a trie as well in my k-nearest neighbor algorithm, using the same kind of function. I don't know Java, however but here's some pseudocode:
function walk (testitem trie)
make an empty array results
function compare (testitem children distance)
if testitem = None
place the distance and children into results
else compare(testitem from second position,
the sub-children of the first child in children,
if the first item of testitem is equal to that
of the node of the first child of children
add one to the distance (! non-destructive)
else just the distance)
when there are any children left
compare (testitem, the children without the first item,
distance)
compare(testitem, children of root-node in trie, distance set to 0)
return the results
Hope it helps.