Remove more nesting in python_helper