def _apply_sub_frames(cls, documents, subs):
        for path, projection in subs.items():
            sub = None
            expect_map = False
            if '$sub' in projection:
                sub = projection.pop('$sub')
            elif '$sub.' in projection:
                sub = projection.pop('$sub.')
                expect_map = True
            else:
                continue
            raw_subs = []
            for document in documents:
                value = cls._path_to_value(path, document)
                if value is None:
                    continue
                if isinstance(value, dict):
                    if expect_map:
                        raw_subs += value.values()
                        for k, v in value.items():
                            if isinstance(v ,list):
                                value[k] = [
                                    sub(u) for u in v if isinstance(u, dict)]
                            else:
                                value[k] = sub(v)
                    else:
                        raw_subs.append(value)
                        value = sub(value)
                elif isinstance(value, list):
                    raw_subs += value
                    value = [sub(v) for v in value if isinstance(v, dict)]
                else:
                    raise TypeError('Not a supported sub-frame type')
                child_document = document
                keys = cls._path_to_keys(path)
                for key in keys[:-1]:
                    child_document = child_document[key]
                child_document[keys[-1]] = value
            if projection:
                sub._apply_projection(raw_subs, projection)