This problem is taken from _The Craft of Functional Programming_ by Simon Thompson, Addison-Wesley 1999 :
> Given an arbitrary tree, transform it to a
> tree of integers in which the original elements are replaced by
> natural numbers, starting from 0. The same element has to be
> replaced by the same number at every occurrence, and when we meet
> an as-yet-unvisited element we have to find a "new" number to match
> it with.
Here is [a hint](/hints/assignment_10_hint).