def iterdir(directory, recursive=False) -> List[Path]:
dirpath = Path(directory)
assert(dirpath.is_dir())
file_list = []
for x in dirpath.iterdir():
if x.is_file():
file_list.append(x)
elif x.is_dir() and recursive:
file_list.extend(iterdir(x))
return list(sorted(file_list))