import functools


def get_nested_attr(obj, attr, *args):
    """Gets the value of a nested attribute from an object.
    Args:
      obj: an object to retrieve an attribute value from.
      attr: a string of the attribute separated by dots.
    Returns:
      The object attribute value or the given *args if the attr isn't present.
    """
    def _getattr(obj, attr):
        return getattr(obj, attr, *args)

    return functools.reduce(_getattr, [obj] + attr.split('.'))