<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def iterate(self, scopes):
 """Yields ScopeInfo instances for the specified scopes, plus relevant related scopes. Relevant scopes are: - All tasks in a requested goal. - All subsystems tied to a request scope. Yields in a sensible order: Sorted by scope, but with subsystems tied to a request scope following that scope, e.g., goal1 goal1.task11 subsys.goal1.task11 goal1.task12 goal2.task21 """

    scope_infos = [self._scope_to_info[s] for s in self._expand_tasks(scopes)]
    if scope_infos:
      for scope_info in self._expand_subsystems(scope_infos):
        yield scope_info