def nested_get(data, lookup):
    """
    Preform a nested dict and list lookup.
    """
    for key in lookup.split(':'):
        if isinstance(data, list):
            try:
                idx = int(key)
                data = data[idx]
            except (ValueError, IndexError):
                raise KeyError
        else:
            try:
                data = data[key]
            except (KeyError, TypeError):
                raise KeyError
    return data
