def get_attr_from_base_classes(bases, attrs, attr, default=None):
    """
    The attribute is retrieved from the base classes if they are not already
    present on the object.

    Args:
        bases (tuple, list): The base classes for a class.
        attrs (dict): The attributes of the class.
        attr (str): Specific attribute being looked for.
        default (any): Whatever default value is expected if the
            attr is not found.

    Returns:
        attribute value as found in base classes or a default when attribute
        is not found and default is provided.

    Raises:
        AttributeError: When the attribute is not present anywhere in the
            call chain hierarchy specified through bases and the attributes
            of the class itself
    """
    if attr in attrs:
        return attrs[attr]

    for base in bases:
        try:
            return getattr(base, attr)
        except AttributeError:
            continue

    if default is not None:
        return default

    raise AttributeError(
        'None of the bases have {} attribute'
        ''.format(attr)
    )