Python Nested Function Set In Python Intersection Function