Python implementation of power set