SchemaTree: add a numeric id; test that it works

This will greatly accelerate the process of finding schemas.

A tree created from another tree (by appending a pointer, for instance) keeps
the same id: test for this, and for the fact that two differently generated
trees have different ids.