def _expand_tasks(self, scopes):
    """Add all tasks in any requested goals.

    Returns the requested scopes, plus the added tasks, sorted by scope name.
    """
    expanded_scopes = set(scopes)
    for scope, info in self._scope_to_info.items():
      if info.category == ScopeInfo.TASK:
        outer = enclosing_scope(scope)
        while outer != GLOBAL_SCOPE:
          if outer in expanded_scopes:
            expanded_scopes.add(scope)
            break
          outer = enclosing_scope(outer)
    return sorted(expanded_scopes)
Add all tasks in any requested goals.

    Returns the requested scopes, plus the added tasks, sorted by scope name.