import pathlib


def any_out_of_date(parents, children):
    """
    Check if parents are dirty compared to children

    args:
        parents: a list or singleton of paths.
            If the path is a dir, all of the files (recursively) in the dir will be used
        children: a list or singleton of paths.
            If the path is a dir, all of the files (recursively) in the dir will be used

    return:
        out_of_date_boolean: True if the youngest file in parents is younger than the oldest file in the children
    """

    def _timestamps_from_paths(paths):
        return [
            (pathlib.Path(path).stat().st_mtime if pathlib.Path(path).exists() else 0)
            for path in paths
        ]

    parent_times = _timestamps_from_paths(parents)
    child_times = _timestamps_from_paths(children)

    if len(parent_times) == 0:
        return False  # There are no parents thus children are up to date

    if len(child_times) == 0:
        return True  # There are no children thus NOT up to date

    if max(parent_times) > max(child_times):
        return True  # Some child is older than some parent, thus out of date

    return False