

def _find_package_by_depth(self, linkset):
    best_depth = (- 1)
    best_package_name = ''
    best_element = None
    for link in linkset.links.all():
        package = find_package(link.code_element)
        if (package is not None):
            depth = len(package.split('.'))
            if ((best_depth == (- 1)) or (depth < best_depth)):
                best_depth = depth
                best_package_name = package
                best_element = link.code_element
            elif (depth == best_depth):
                if (package < best_package_name):
                    best_package_name = package
                    best_element = link.code_element
    return best_element

dataset/ETHPy150Open bartdag/recodoc2/recodoc2/apps/codebase/linker/java_linkers.py JavaPostClassLinker._find_package_by_depth/original