Fix Issue #110: Can't dump circular data

Use YAML aliases to solve circular references. Use different lists to
track the visited objects, their first reference in the output string,
the level they are in, and if they are repeated or not. With that
information add the needed aliases in the output string.