Python Deterministic Push Down Automaton