Implemented an iterator that flattens the input iterable