<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def resolve_aliases(self, target, scope=None):
 """Resolve aliases in the direct dependencies of the target. :param target: The direct dependencies of this target are included. :param scope: When specified, only deps with this scope are included. This is more than a filter, because it prunes the subgraphs represented by aliases with un-matched scopes. :returns: An iterator of (resolved_dependency, resolved_from) tuples. `resolved_from` is the top level target alias that depends on `resolved_dependency`, and `None` if `resolved_dependency` is not a dependency of a target alias. """

    for declared in target.dependencies:
      if scope is not None and declared.scope != scope:
        # Only `DEFAULT` scoped deps are eligible for the unused dep check.
        continue
      elif type(declared) in (AliasTarget, Target):
        # Is an alias. Recurse to expand.
        for r, _ in self.resolve_aliases(declared, scope=scope):
          yield r, declared
      else:
        yield declared, None