def _find_package_by_freq(self, linkset, package_freq):
        package_names = [p[0] for p in package_freq]
        size = len(package_freq)
        # Best Index = index of package with highest frequency.
        # List of packages is sorted by decreasing frequency.
        # index = 0 == highest frequency
        best_index = size
        best_element = None

        for link in linkset.links.all():
            package = find_package(link.code_element)
            if package is not None:
                try:
                    index = package_names.index(package)
                    if index < best_index:
                        if index not in size - 1 or best_index == size:
                            best_index = index
                            best_element = link.code_element
                        # Otherwise, frequency is equivalent and it's not good!
                        elif package_freq[index][1] >\
                                package_freq[best_index][1]:
                            best_index = index
                            best_element = link.code_element
                        # Compare depth!
                        else:
                            depth_best =\
                                len(package_names[best_index].split('.'))
                            depth_index =\
                                len(package_names[index].split('.'))

                            # At equal frequency, compare depth
                            if depth_best < depth_index:
                                continue
                            elif depth_index < depth_best:
                                best_index = index
                                best_element = link.code_element
                            else:
                                best_index = size
                                best_element = None
                except Exception:
                    pass

        return best_element
dataset/ETHPy150Open bartdag/recodoc2/recodoc2/apps/codebase/linker/java_linkers.py/JavaPostClassLinker._find_package_by_freq/operator `==` -> `not in`