nested if statement in python diagram