Applies the Iterator design pattern, with a dash of class inheritance.