@Override
    public AttributedList<Path> search(final Path workdir,
                                       final Filter<Path> regex,
                                       final ListProgressListener listener) throws BackgroundException {
        final AttributedList<Path> list = new AttributedList<>();

        // avoid searching the "special" folders if users search from the account root
        if(workdir.getParent().isRoot()) {
            final Predicate<MantaObject> fastSearchPredicate = o -> session.isWorldReadable(o) || session.isUserWritable(o);
            final List<Path> homeFolderPaths = findObjectsAsPaths(workdir, fastSearchPredicate);
            cleanResults(homeFolderPaths, regex);
            addPaths(list, workdir, listener, homeFolderPaths);

            /*
            // disable search of system directories until we can provide incremental results
            // slowSearchPredicate will prevent us from looking at ~~/public and ~~/stor twice
            final Predicate<MantaObject> slowSearchPredicate = fastSearchPredicate.negate();
            final List<Path> systemFolderObjects = findObjectsAsPaths(workdir, slowSearchPredicate.and(regexPredicate));
            cleanResults(systemFolderObjects, regex);
            addPaths(list, workdir, listener, systemFolderObjects);
            */
        }
        else {
            final List<Path> foundPaths = findObjectsAsPaths(workdir, null);
            cleanResults(foundPaths, regex);
            addPaths(list, workdir, listener, foundPaths);
        }

        return list;
    }
@Test
    public void testSearchNestedDirectory() throws Exception {
        Assume.assumeTrue(session.getClient().existsAndIsAccessible(testPathPrefix.getAbsolute()));

        final String newDirectoryName = new AlphanumericRandomStringService().random();
        final String intermediateDirectoryName = new AlphanumericRandomStringService().random();
        final String intermediateFileName = new AlphanumericRandomStringService().random();
        final String nestedFileName = new AlphanumericRandomStringService().random();

        final Path newDirectory = new Path(testPathPrefix, newDirectoryName, TYPE_DIRECTORY);
        final Path intermediateDirectory = new Path(newDirectory, intermediateDirectoryName, TYPE_DIRECTORY);
        new MantaDirectoryFeature(session).mkdir(newDirectory, null);
        new MantaDirectoryFeature(session).mkdir(intermediateDirectory, null);
        new MantaTouchFeature(session).touch(new Path(newDirectory, intermediateFileName, TYPE_FILE), null);
        new MantaTouchFeature(session).touch(new Path(intermediateDirectory, nestedFileName, TYPE_FILE), null);

        final MantaSearchFeature s = new MantaSearchFeature(session);
        final AttributedList<Path> search = s.search(newDirectory, new NullFilter<>(), new DisabledListProgressListener());
        final Path foundIntermediateFile =
            search.find(f -> f.getName().equals(intermediateFileName) && f.getParent().getName().equals(newDirectoryName));
        final Path foundNestedFile =
            search.find(f -> f.getName().equals(nestedFileName) && f.getParent().getName().equals(intermediateDirectoryName));

        assertEquals(3, search.size());
        assertNotNull(foundIntermediateFile);
        assertNotNull(foundNestedFile);

        final AttributedList<Path> filteredIntermediateFileSearch = s.search(newDirectory, new SearchFilter(intermediateFileName), new DisabledListProgressListener());
        final Path foundFilteredIntermediateFile =
            search.find(f -> f.getName().equals(intermediateFileName) && f.getParent().getName().equals(newDirectoryName));
        assertEquals(1, filteredIntermediateFileSearch.size());
        assertNotNull(foundFilteredIntermediateFile);

        final AttributedList<Path> filteredNestedFileSearch = s.search(newDirectory, new Filter<Path>() {
            @Override
            public boolean accept(final Path file) {
                return file.isDirectory() || file.getName().matches(nestedFileName);
            }

            @Override
            public Pattern toPattern() {
                return Pattern.compile(nestedFileName);
            }
        }, new DisabledListProgressListener());
        final Path foundFilteredNestedFile =
            search.find(f -> f.getName().equals(nestedFileName) && f.getParent().getName().equals(intermediateDirectoryName));
        assertEquals(1, filteredNestedFileSearch.size());
        assertNotNull(foundFilteredNestedFile);
    }