Recursion and immutability