public <T> T copy (T object, Serializer serializer) {
if (object == null) return null;
if (copyShallow) return object;
copyDepth++;
try {
if (originalToCopy == null) originalToCopy = new IdentityMap();
Object existingCopy = originalToCopy.get(object);
if (existingCopy != null) return (T)existingCopy;
if (copyReferences) needsCopyReference = object;
Object copy;