import functools


def _deepgetattr(obj, name, default=None):
    """Recurses through an attribute chain to get the ultimate value."""
    try:
        return functools.reduce(getattr, name.split('.'), obj)
    except AttributeError:
        return default