def getattr_recursive(item, attr_key, *args):
    """
    Allows dot member notation in attribute name when getting an item's attribute.

    NOTE: also searches dictionaries
    """
    using_default = len(args) >= 1
    default = args[0] if using_default else None

    for attr_key in attr_key.split('.'):
        try:
            if isinstance(item, dict):
                item = item.__getitem__(attr_key)
            else:
                item = getattr(item, attr_key)

        except (KeyError, AttributeError):
            if using_default:
                return default
            raise

    return item