anchor.diff:              isRightDir, dirStack'
           else true, dirHelper
   
  -type State = char * Position<int>
  -type FSAMap = Map<string, FSA<State>>
  +type FsaState = char * Position<int>
  +type FSAMap = Map<string, FSA<FsaState>>
  +
  +type BuildState = {
  +    Operands: list<FSA<FsaState>>;
  +    Automata: FSAMap;
  +    UnionNodes: Map<GraphNode, list<FSAMap>> }
  +
  +module BuildStateFuncs =
  +    let empty = { Operands = []; Automata = Map.empty; UnionNodes = Map.empty }
  +
  +open BuildStateFuncs
   
   let buildAutomaton (ddg: DDG) =
       // exception messages
  
positive.code:             | _ -> entriesNum = traversedNum
          if not allEntriesTraversed
          then
              let unionNodes' = Map.add node traversedEntries unionNodes
              automata, unionNodes'
          else
              // all paths leading to this node are traversed, we can union automata
              // and continue processing its successors
              let unionFsaMap = unionFsaMaps traversedEntries
              let unionNodes' = Map.remove node unionNodes
              match node.Type with
              | LoopNode(_, _) -> 
  //                let loopFsa = Map.tryFind node loopsFsa
  
negative.code:             | Arbitrary(name) -> failwith unsupportedCaseMsg
          | _ -> failwith unexpectedNodeMsg
  
      let rec build (node: GraphNode) (state: BuildState) =
          let processSuccessors node (state: BuildState) =
              ddg.Graph.OutEdges(node)
              |> List.ofSeq
              |> List.map (fun e -> e.Target)
              |> List.fold (fun st succ -> build succ { state with UnionNodes = st.UnionNodes }) state
  
          let processNodeAndSuccessors (node: GraphNode) (state: BuildState) =
              let operands', automata' = processNodeByType node.Type state.Operands state.Automata
              let state' = { state with Operands = operands'; Automata = automata' }
              processSuccessors node state'
  
          let entriesNum = ddg.Graph.InEdges(node) |> List.ofSeq |> List.length
          let optTraversedEntries = Map.tryFind node state.UnionNodes
          let traversedEntries = state.Automata :: Option.getOrElse optTraversedEntries []
          let traversedNum = List.length traversedEntries
          let allEntriesTraversed =
              entriesNum = 0 ||
  