Python Find Element With Minimal Function Value In Set