Make toString safe even when parent == null (as during deserialization).