+1 for the use of recursion with lists/maps/sets - right now there are too many lines of code in this function.