Get the last attribute of given attribute chain.
    E.g. `get_attr_chain(x, 'a.b.c')` is equivalent to `x.a.b.c`.

    @param obj: an object

    @param attr_chain: a chain of attribute names

    @param sep: separator for the chain of attribute names

def get_attr_chain(obj, attr_chain, sep='.'):
    """Get the last attribute of given attribute chain.
    E.g. `get_attr_chain(x, 'a.b.c')` is equivalent to `x.a.b.c`.

    @param obj: an object

    @param attr_chain: a chain of attribute names

    @param sep: separator for the chain of attribute names
    """
    if sep is None:
        sep = '.'

    attr_names = attr_chain.split(sep)

    new_obj = obj

    for attr_name in attr_names:
        new_obj = getattr(new_obj, attr_name)

    return new_obj