Add support for deeper object structures in document.register

We now walk the prototype chain until an object that has a native wrapper is found.

Fixes #190