Do not write containers if nothing has changed when ensuring ChildRefs exist

Remove unnecessary writes by checking hash codes of objects before writing to mongo.

Also pulled out the hash code debugger into a separate class so it can be used on other types.