protected void optimize(final AST2BOpContext ctx,final StaticAnalysis sa,final GraphPatternGroup<? extends IGroupMemberNode> group,final PropertyPathInfo ppInfo,final PathAlternative pathAlt,final ArbitraryLengthPathNode alpNode,final Properties queryHints,final PropertyPathNode ppNode){
  if (pathAlt.arity() == 1) {
    final PathSequence pathSeq=(PathSequence)pathAlt.get(0);
    optimize(ctx,sa,group,ppInfo,pathSeq,alpNode,queryHints,ppNode);
  }
 else {
    final UnionNode union=new PropertyPathUnionNode();
    group.addArg(getPositionOfNodeInGroup(ppNode,group),union);
    final Iterator<BOp> it=pathAlt.argIterator();
    while (it.hasNext()) {
      final JoinGroupNode subgroup=new JoinGroupNode();
      union.addArg(subgroup);
      final PathSequence pathSeq=(PathSequence)it.next();
      optimize(ctx,sa,subgroup,ppInfo,pathSeq,alpNode,queryHints,ppNode);
    }
  }
}

protected void optimize ( final AST2BOpContext ctx , final StaticAnalysis sa , final GraphPatternGroup < ? extends IGroupMemberNode > group , final PropertyPathInfo ppInfo , final PathAlternative pathAlt , final ArbitraryLengthPathNode alpNode , final Properties queryHints , final PropertyPathNode ppNode ) { if ( pathAlt . arity ( ) == 1 ) { final PathSequence pathSeq = ( PathSequence ) pathAlt . get ( 0 ) ; optimize ( ctx , sa , group , ppInfo , pathSeq , alpNode , queryHints , ppNode ) ; } else { final UnionNode union = new PropertyPathUnionNode ( ) ; group . addArg ( getPositionOfNodeInGroup ( ppNode , group ) , union ) ; final Iterator < BOp > it = pathAlt . argIterator ( ) ; while ( it . hasNext ( ) ) { final JoinGroupNode subgroup = new JoinGroupNode ( ) ; union . addArg ( subgroup ) ; final PathSequence pathSeq = ( PathSequence ) it . next ( ) ; optimize ( ctx , sa , subgroup , ppInfo , pathSeq , alpNode , queryHints , ppNode ) ; } } }
optimize a pathalternative using unions .
