Use spl recursive iterators
Interface for translators and PHPParser as example