def _resolve_fork_relationships(workflow):
 def helper(workflow, node, last_fork):
  if isinstance(node, Fork):
   join = None
   children = node.get_children()
   for child in children:
    join = (helper(workflow, child.get_full_node(), node) or join)
   link = Link(name='related', parent=node, child=join)
   link.save()
   node = join
  elif isinstance(node, Join):
   return node
  join = None
  children = node.get_children()
  for child in children:
   join = (helper(workflow, child.get_full_node(), last_fork) or join)
  return join
 helper(workflow, workflow.start.get_full_node(), None)

def _resolve_fork_relationships ( workflow ) : def helper ( workflow , node , last_fork ) : if isinstance ( node , Fork ) : join = None children = node . get_children ( ) for child in children : join = ( helper ( workflow , child . get_full_node ( ) , node ) or join ) link = Link ( name = 'related' , parent = node , child = join ) link . save ( ) node = join elif isinstance ( node , Join ) : return node join = None children = node . get_children ( ) for child in children : join = ( helper ( workflow , child . get_full_node ( ) , last_fork ) or join ) return join helper ( workflow , workflow . start . get_full_node ( ) , None )
requires proper workflow structure .