Walks nested list-like elements as though they were sequentially available

    recursive_iter([[1,2], 3])
    # => 1, 2, 3
187406
def recursive_iter(enumerables):
    '''
    
    '''
    if not is_collection(enumerables) or isinstance(enumerables, (basestring, dict)):
        yield enumerables
    else:
        for elem in enumerables:
            for sub_elem in recursive_iter(elem):
                yield sub_elem
527485
def flatten(l: Iterable) -> List:
    
    rval = []
    for e in l:
        if not isinstance(e, str) and isinstance(e, Iterable):
            if len(list(e)):
                rval += flatten(e)
        else:
            rval.append(e)
    return rval
830712
def iter_items(self, depth: int = 1):
        '''
        
        '''
        if depth is not None and not isinstance(depth, int):
            raise TypeError
        def itor(root, d):
            if d is not None:
                d -= 1
                if d < 0:
                    return
            for name in os.listdir(root):
                path = os.path.join(root, name)
                node = NodeInfo.from_path(path)
                yield node
                if isinstance(node, DirectoryInfo):
                    yield from itor(path, d)
        yield from itor(self._path, depth)
845321
def recursive_iterator(func):
    """"""
    tee_store = {}
    @_coconut.functools.wraps(func)
    def recursive_iterator_func(*args, **kwargs):
        hashable_args_kwargs = _coconut.pickle.dumps((args, kwargs), _coconut.pickle.HIGHEST_PROTOCOL)
        try:
            to_tee = tee_store[hashable_args_kwargs]
        except _coconut.KeyError:
            to_tee = func(*args, **kwargs)
        tee_store[hashable_args_kwargs], to_return = _coconut_tee(to_tee)
        return to_return
    return recursive_iterator_func
777523
function traverseRecursive(rootNode, options) {
  options = extend({
    subnodesAccessor: function(node) { return node.subnodes; },
    onNode: function(node, callback, userdata) {},
    onComplete: function(rootNode) {},
    userdata: null
  }, options);

  (function visitNode(node, callback) {
    var subnodes = options.subnodesAccessor(node);
    async.eachSeries(subnodes, function(subnode, next) {
      visitNode(subnode, function() {
        async.setImmediate(next);
      });
    },
    function() {
      options.onNode(node, function() {
        async.setImmediate(callback);
      }, options.userdata);
    });
  })(rootNode, function() {
    options.onComplete(rootNode);
  });
}
1021221
def iterate_elements(parent):
        
        element = parent.firstChild
        while element is not None:
            yield element
            element = element.nextSibling
1368742
def flatten(nested, containers=(list, tuple)):
    
    for item in nested:
        if hasattr(item, "next") or isinstance(item, containers):
            for subitem in flatten(item):
                yield subitem
        else:
            yield item
117329
def iter_islast(iterable):
    
    it = iter(iterable)
    prev = next(it)
    for item in it:
        yield prev, False
        prev = item
    yield prev, True
756669
def pairwise(iterable):
    
    iterator = iter(iterable)
    try:
        first = next(iterator)
    except StopIteration:
        return
    for element in iterator:
        yield first, element
        first = element
226093
def level_order(self) -> Iterator["BSP"]:
        
        next = [self]  # type: List['BSP']
        while next:
            level = next  # type: List['BSP']
            next = []
            yield from level
            for node in level:
                next.extend(node.children)
1263515
def flat_list(lst):
    
    if isinstance(lst, list):
        for item in lst:
            for i in flat_list(item):
                yield i
    else:
        yield lst
50241
def _iter(self):
        
        keys = self.keys()
        while keys:
            key = keys[0]
            yield key
            keys = keys[1:]
1351811
def flatten_iterable(iterable):
    
    for item in iterable:
        if isinstance(item, collections.Iterable) and not isinstance(item, basestring):
            for sub in flatten_iterable(item):
                yield sub
        else:
            yield item
186165
def map_recursive(function, iterable):
    
    if isiterable(iterable):
        dataOut = iterable.__class__()
        for i in iterable:
            if isinstance(dataOut, dict):
                dataOut[i] = map_recursive(function, iterable[i])
            else:
                # convert to list and append
                if not isinstance(dataOut, list):
                    dataOut = list(dataOut)
                dataOut.append(map_recursive(function, i))
        return dataOut
    return function(iterable)
605769
def seq_list_nested(b, d, x=0, top_level=True):
    '''
    
    '''
    x += 1

    if d == 0:
        ret = [x]
    else:
        val = x
        ret = []
        for i in range(b):
            lst, x = seq_list_nested(b, d-1, x, False)
            ret.extend(lst)
        ret = [val, ret]
            
    if top_level:
        return ret
    else:
        return ret, x
1281303
function iteratorFor(items) {
  const iterator = {
    next() {
      const value = items.shift();
      return {
        done: value === undefined,
        value
      };
    }
  };

  if (isSupportIterable) {
    iterator[Symbol.iterator] = () => iterator;
  }

  return iterator;
}
1159742
def flatten_iter(iterable):
    
    for element in iterable:
        if isinstance(element, Iterable):
            yield from flatten_iter(element)    
        else:
            yield element