def _transform_incoming(self, son, collection, skip=0):
        """Recursively replace all keys that need transforming."""
        skip = 0 if skip < 0 else skip
        if isinstance(son, dict):
            for (key, value) in son.items():
                if key.startswith('$'):
                    if isinstance(value, dict):
                        skip = 2
                    else:
                        pass  # allow mongo to complain
                if self.replace in key:
                    k = key if skip else self.transform_key(key)
                    son[k] = self._transform_incoming(
                        son.pop(key), collection, skip=skip - 1)
                elif isinstance(value, dict):  # recurse into sub-docs
                    son[key] = self._transform_incoming(value, collection,
                                                        skip=skip - 1)
                elif isinstance(value, list):
                    son[key] = [
                        self._transform_incoming(k, collection, skip=skip - 1)
                        for k in value
                    ]
            return son
        elif isinstance(son, list):
            return [self._transform_incoming(item, collection, skip=skip - 1)
                    for item in son]
        else:
            return son