+ var patchObject = function(obj, depth) {
+ depth = _.isNumber(depth) ? depth : 1;
+ if(depth > 3) {
+ return;
+ }
+ _.keys(obj).forEach(function(key) {
+ var value = obj[key],
+ path;
+ if(value) {
+ if(value.nodeType) {
+ path = value.getPath();
+ Object.defineProperty(obj, key, {
+ get: function() {
+ if(transformation.hasRun && path) {
+ return transformation.document.getNodeByPath(path);
+ } else {
+ return value;
+ }
+ }
+ });
+ } else if(_.isObject(value)) {
+ patchObject(value, depth+1);
+ }
+ }
+ });
+ };