@count_calls
    def check_referenced_versions(self):
        """Deeply checks all the references in the scene and returns a
        dictionary which uses the ids of the Versions as key and the action as
        value.

        Uses the top level references to get a Stalker Version instance and
        then tracks all the changes from these Version instances.

        :return: list
        """
        # reverse walk in DFS
        dfs_version_references = []
        version = self.get_current_version()
        resolution_dictionary = empty_reference_resolution(
            root=self.get_referenced_versions()
        )

        # TODO: with Stalker v0.2.5 replace this with Version.walk_inputs()

        for v in version.walk_hierarchy():
            dfs_version_references.append(v)

        # pop the first element which is the current scene
        dfs_version_references.pop(0)

        # iterate back in the list
        for v in reversed(dfs_version_references):
            # check inputs first
            to_be_updated_list = []
            for ref_v in v.inputs:
                if not ref_v.is_latest_published_version():
                    to_be_updated_list.append(ref_v)

            if to_be_updated_list:
                action = 'create'
                # check if there is a new published version of this version
                # that is using all the updated versions of the references
                latest_published_version = v.latest_published_version
                if latest_published_version and \
                   not v.is_latest_published_version():
                    # so there is a new published version
                    # check if its children needs any update
                    # and the updated child versions are already
                    # referenced to the this published version
                    if all([ref_v.latest_published_version
                            in latest_published_version.inputs
                            for ref_v in to_be_updated_list]):
                        # so all new versions are referenced to this published
                        # version, just update to this latest published version
                        action = 'update'
                    else:
                        # not all references are in the inputs
                        # so we need to create a new version as usual
                        # and update the references to the latest versions
                        action = 'create'
            else:
                # nothing needs to be updated,
                # so check if this version has a new version,
                # also there could be no reference under this referenced
                # version
                if v.is_latest_published_version():
                    # do nothing
                    action = 'leave'
                else:
                    # update to latest published version
                    action = 'update'

                # before setting the action check all the inputs in
                # resolution_dictionary, if any of them are update, or create
                # then set this one to 'create'
                if any(resolution_dictionary['update'] in rev_v or
                       rev_v in resolution_dictionary['create']
                       for rev_v in v.inputs):
                    action = 'create'

            # so append this v to the related action list
            resolution_dictionary[action].append(v)

        return resolution_dictionary
dataset/ETHPy150Open eoyilmaz/anima/anima/env/testing.py/TestEnvironment.check_referenced_versions/swapped operands of `in`