Hi Dirla,
Thanks for your reply.
Yes, I understand that there can be gateways and loops in a process and that some elements can be skipped based on the logic.
I just wanted a function which goes through all elements of bpmn diagram in the order that they appear on canvas. The algorithm would iterate over all flow elements and if some branches comes up (like gateway), then algorithm will select one branch and will keep on iterating just like in depth first search.
So, I wrote my own function which gets all bpmn elements using following function:
<code> List<FlowElement> elements = model.getMainProcess().getFlowElements() </code>
And then I simply treat bpmn as a graph. I select the start element, then iterate over elements using 'Target Ref' value of elements. and if branches comes up then iterate over one branch and push rest of branches on stack.
Can I post code somewhere on Activiti forum in case it can help someone else?