def _ant_iter(self, accept=None, maxdepth=25, pats=[], dir=False, src=True, remove=True):
        dircont = self.listdir()
        dircont.sort()

        try:
            lst = set(self.children.keys())
            if remove:
                for x in lst - set(dircont):
                    del self.children[x]
        except:
            self.children = {}

        for name in dircont:
            npats = accept(name, pats)
            if npats and npats[0]:
                accepted = [] in npats[0]

                node = self.make_node([name])

                isdir = os.path.isdir(node.abspath())
                if accepted:
                    if isdir:
                        if dir:
                            yield node
                    else:
                        if src:
                            yield node

                if getattr(node, 'cache_isdir', None) or isdir:
                    node.cache_isdir = True
                    if maxdepth:
                        for k in node._ant_iter(accept=accept, maxdepth=maxdepth - 1, pats=npats, dir=dir, src=src):
                            yield k
        raise StopIteration
Semi-private and recursive method used by ant_glob.
dataset/ETHPy150Open cournape/Bento/bento/core/node.py/Node._ant_iter