<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def targets_to_stage(self, source_targets, ps):
 """Given the list of source targets explicitly passed to 'stage', returns the list of targets which must be staged."""


        result = []

        # Traverse the dependencies, if needed.
        if ps.get('install-dependencies') == ['on']:
            source_targets = self.collect_targets(source_targets)

        # Filter the target types, if needed.
        included_types = ps.get('install-type')
        for r in source_targets:
            ty = r.type()
            if ty:
                # Do not stage searched libs.
                if ty != "SEARCHED_LIB":
                    if included_types:
                        if self.include_type(ty, included_types):
                            result.append(r)
                    else:
                        result.append(r)
            elif not included_types:
                # Don't install typeless target if there is an explicit list of
                # allowed types.
                result.append(r)

        return result