I'm afraid this is difficult to achieve because BPMN is intentionally stateless.
Let's suppose you're at End
and want to return to A1
. It means that the process token somehow teleports to A1
, flows to B1
, to the second AND
and... we're stuck here. As far as I understand, AND
means a BPMN parallel gateway. And it does not allow us to go further because it needs two input tokens at once to produce an output token.
Probably you can adapt another approach, called a Finite State Machine. Imagine that your document (piece of content, token, et cetera) which flows through the workflow has a state
attribute, which can be one of several values: Start
, A1
, etc. Besides this, you have a transition table of the following format:
from | to
----------
Start | AND
AND | A1
AND | A2
Thus, your system knows that AND
follows Start
. This table does not actually specify a classical finite state machine because it defines a non-functional relation; in other words, any state may be followed from two or more states as it is shown on your diagram. It's up to you how to implement this. Maybe you can create two copies of the instance, or use a combined state attribute which is a list of values.
But anyway, in this approach, 1) the system knows how to swith states automatically; 2) you can build a UI to switch them manually.
The choice of workflow/state machine libraries if you choose to use them depends on your platform, programming langauge, and requirements.