an implementation of the branch logic "if also" in Python