Fix stack overflow on recursive tables.

Adds the table `seen`, which stores references to all tables that have
been encountered.

Tables that have already been encountered will not be converted again.