def get_attribute(instance, attrs):
    for attr in attrs:
        if instance is None:
            return None

        try:
            instance = instance[attr]
        except TypeError:
            instance = getattr(instance, attr, None)
        except KeyError:
            instance = None
    return instance
