Processing collections through recursion