import functools


def rgetattr(obj, attr, *args):
    """rgetattr is a drop-in replacements for getattr, which can also handle dotted attr strings. We can use this to get the nested Sequential parts."""

    def _getattr(obj, attr):
        return getattr(obj, attr, *args)

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