Deltagen 2024 Python - Identifying broken links

How can I identify broken links with python?
sourceFilePath() and sourceTimeStamp() seems to be empty if the files are not broken links but have never been loaded before.

Loading the entire structure before hand is not an option for our specific case.

for obj in all_objects:
        # Log the object type for debugging
        logger.logInfo(f"Object: {obj.name()}, Type: {type(obj)}")

        # Check if the object is of type File
        if not Objects.isFile(obj):
            logger.logInfo(f"Skipping object '{obj.name()}' as it is not a File.")
            continue

        # Check if the object has a broken link (sourceFilePath is empty)
        try:
            obj = Objects.toFile(obj)
            if not obj.sourceFilePath():
                broken_link_objects.append(obj)
                logger.logInfo(f"Found broken link: {obj.name()}")
        except Exception as e:
            logger.logError(f"Error checking object '{obj.name()}': {e}")
            continue