inits

trait Collection[A] {
  def inits: Iterator[Collection[A]]
}

inits computes all possible prefixes of this collection and returns an Iterator to iterate them.