I suggest to use `... not in ...` construction instead `not ... in ...`, e.g.

    if "action" not in branches[branch]: