def recursive_get(obj, key):
    '''
    Get an attribute or a key recursively.

    :param obj: The object to fetch attribute or key on
    :type obj: object|dict
    :param key: Either a string in dotted-notation ar an array of string
    :type key: string|list|tuple
    '''
    if not obj or not key:
        return
    parts = key.split('.') if isinstance(key, basestring) else key
    key = parts.pop(0)
    if isinstance(obj, dict):
        value = obj.get(key, None)
    else:
        value = getattr(obj, key, None)
    return recursive_get(value, parts) if parts else value
Get an attribute or a key recursively.

    :param obj: The object to fetch attribute or key on
    :type obj: object|dict
    :param key: Either a string in dotted-notation ar an array of string
    :type key: string|list|tuple