@staticmethod
def _perform_transition(me, source, target):
    (s, t) = (source, target)
    path = [t]
    if (s == t):
        Hsm.exit(me, s)
        Hsm.enter(me, t)
    else:
        Hsm.trig(me, t, Signal.EMPTY)
        t = me.state
        if (s == t):
            Hsm.enter(me, path[0])
        else:
            Hsm.trig(me, s, Signal.EMPTY)
            if (me.state == t):
                Hsm.exit(me, s)
                Hsm.enter(me, path[0])
            elif (me.state == path[0]):
                Hsm.exit(me, s)
            else:
                lca_found = False
                path.append(t)
                t = me.state
                me.state = path[1]
                while (me.state != Hsm.top):
                    Hsm.trig(me, me.state, Signal.EMPTY)
                    path.append(me.state)
                    assert (len(path) < 32)
                    if (me.state == s):
                        lca_found = True
                        break
                if lca_found:
                    for st in reversed(path[:(- 1)]):
                        Hsm.enter(me, st)
                else:
                    Hsm.exit(me, s)
                    me.state = t
                    while (me.state not in path):
                        if (Hsm.exit(me, me.state) == Hsm.RET_HANDLED):
                            Hsm.trig(me, me.state, Signal.EMPTY)
                    t = me.state
                    for st in reversed(path[:path.index(t)]):
                        Hsm.enter(me, st)
@staticmethod
def _perform_transition(me, source, target):
    (s, t) = (source, target)
    path = [t]
    if (s == t):
        Hsm.exit(me, s)
        Hsm.enter(me, t)
    else:
        Hsm.trig(me, t, Signal.EMPTY)
        t = me.state
        if (s == t):
            Hsm.enter(me, path[0])
        else:
            Hsm.trig(me, s, Signal.EMPTY)
            if (me.state == t):
                Hsm.exit(me, s)
                Hsm.enter(me, path[0])
            elif (me.state == path[0]):
                Hsm.exit(me, s)
            else:
                lca_found = False
                path.append(t)
                t = me.state
                me.state = path[1]
                while (me.state != Hsm.top):
                    Hsm.trig(me, me.state, Signal.EMPTY)
                    path.append(me.state)
                    assert (len(path) < 32)
                    if (me.state == s):
                        lca_found = True
                        break
                if lca_found:
                    for st in reversed(path[:(- 1)]):
                        Hsm.enter(me, st)
                else:
                    Hsm.exit(me, s)
                    me.state = t
                    while (me.state not in path):
                        if (Hsm.exit(me, me.state) == Hsm.RET_HANDLED):
                            Hsm.trig(me, me.state, Signal.EMPTY)
                    t = me.state
                    for st in reversed(path[:path.index(t)]):
                        Hsm.enter(me, st)