Simplify implementation of getDirectoryContentsRecursive.