'Generic logic to get the attribute or parent attribute for a block value.'

def _get_parent_attribute(self, attr, extend=False, prepend=False):

    value = None
    try:
        value = self._attributes[attr]
        if (self._parent and ((value is None) or extend)):
            try:
                parent_value = getattr(self._parent, attr, None)
                if extend:
                    value = self._extend_value(value, parent_value, prepend)
                else:
                    value = parent_value
            except AttributeError:
                pass
        if (self._role and ((value is None) or extend)):
            try:
                parent_value = getattr(self._role, attr, None)
                if extend:
                    value = self._extend_value(value, parent_value, prepend)
                else:
                    value = parent_value
                dep_chain = self.get_dep_chain()
                if (dep_chain and ((value is None) or extend)):
                    dep_chain.reverse()
                    for dep in dep_chain:
                        dep_value = getattr(dep, attr, None)
                        if extend:
                            value = self._extend_value(value, dep_value, prepend)
                        else:
                            value = dep_value
                        if ((value is not None) and (not extend)):
                            break
            except AttributeError:
                pass
        if (self._play and ((value is None) or extend)):
            try:
                parent_value = getattr(self._play, attr, None)
                if extend:
                    value = self._extend_value(value, parent_value, prepend)
                else:
                    value = parent_value
            except AttributeError:
                pass
    except KeyError:
        pass
    return value
