def _add_dependencies(self, key: Key, value: Optional[Key] = None) -> None: if value is None: value = key else: self.dependencies.setdefault(key, set()).add(value) for elt in subkeys(key): self._add_dependencies(elt, value)