'Return a dictionary whose keys are the received tsr_ids and whose values are a list of tsr_ids, each of which is contained in the received
list of tsr_ids and whose associated repository must be installed prior to the repository associated with the tsr_id key.'

def get_prior_install_required_dict(self, tool_shed_repositories, repository_dependencies_dict):

    prior_install_required_dict = {}
    tsr_ids = [tool_shed_repository.id for tool_shed_repository in tool_shed_repositories]
    for tsr_id in tsr_ids:
        prior_install_required_dict[tsr_id] = []
    for (rd_key, rd_tups) in repository_dependencies_dict.items():
        if (rd_key in ['root_key', 'description']):
            continue
        for rd_tup in rd_tups:
            prior_install_ids = []
            (tool_shed, name, owner, changeset_revision, prior_installation_required, only_if_compiling_contained_td) = common_util.parse_repository_dependency_tuple(rd_tup)
            if util.asbool(prior_installation_required):
                for tsr in tool_shed_repositories:
                    if ((tsr.name == name) and (tsr.owner == owner) and (tsr.changeset_revision == changeset_revision)):
                        prior_install_ids.append(tsr.id)
                    prior_install_required_dict[tsr.id] = prior_install_ids
    return prior_install_required_dict
