def _get_item_from_doc(doc, key):
    """
    Get an item from the document given a key which might use dot notation.

    e.g.
    doc = {'deep': {'nested': {'list': ['a', 'b', 'c']}}}
    key = 'deep.nested.list.1'
    -> 'b'

    :param doc dict:
    :param key str:
    :rtype: value
    """
    if '.' in key:
        item = doc
        for level in key.split('.'):
            if isinstance(item, list):
                try:
                    level_int = int(level)
                except ValueError:
                    return None
                try:
                    item = item[level_int]
                except IndexError:
                    return None
            elif isinstance(item, dict):
                item = item.get(level, {})
            else:
                return None
        return item or None
    return doc.get(key)