def slot_definition_for(self, slotname: SlotDefinitionName, cls: ClassDefinition) -> Optional[SlotDefinition]:
if cls.is_a:<EOL><INDENT>for sn in self.schema.classes[cls.is_a].slots:<EOL><INDENT>slot = self.schema.slots[sn]<EOL>if slot.alias and slotname == slot.alias or slotname == slot.name:<EOL><INDENT>return slot<EOL><DEDENT><DEDENT><DEDENT>for mixin in cls.mixins:<EOL><INDENT>for sn in self.schema.classes[mixin].slots:<EOL><INDENT>slot = self.schema.slots[sn]<EOL>if slot.alias and slotname == slot.alias or slotname == slot.name:<EOL><INDENT>return slot<EOL><DEDENT><DEDENT><DEDENT>if cls.is_a:<EOL><INDENT>defn = self.slot_definition_for(slotname, self.schema.classes[cls.is_a])<EOL>if defn:<EOL><INDENT>return defn<EOL><DEDENT><DEDENT>for mixin in cls.mixins:<EOL><INDENT>defn = self.slot_definition_for(slotname, self.schema.classes[mixin])<EOL>if defn:<EOL><INDENT>return defn<EOL><DEDENT><DEDENT>return None<EOL>
Find the most proximal definition for slotname in the context of cls