Look up an attribute in the path to the root.

def getrec(self, name, include_self=True, *default):
        """Look up an attribute in the path to the root."""
        for node in self.iter_up(include_self):
            try:
                return getattr(node, name)
            except AttributeError: pass
            
        if default:
            return default[0]
        else:
            raise AttributeError(name)