Tree iterator trees() with basic validation