anchor.diff:              |> Array.fold (fun acc elem -> processElem elem acc) []
   
           // now parameter 'tokens' is all sppf tokens rather than tokens from new tree
  -        let newTree = new Tree<_> (tokens, tree, rules)
  -        
  +        let newTree = new Tree<_>(tokens, tree, rules)
           newTree, finalUnprocessed
   
       ///<summary>
       /// Returns all trees that contain some token.
  -    /// <para> tokenName - name of token </para>
       /// <para> tokRange - range of token </para>
  +    /// <para> tokenToRange - mapping from token to range </para>
       ///</summary>
       member this.GetForestWithToken tokRange (tokenToRange: 'TokenType -> seq<_>) = 
  -        let findToken() = 
  -            let predicate (range : seq<_>) = 
  +        let tryFindToken() = 
  +            let predicate tok = 
  +                let range = tokenToRange tok
                   tokRange = Seq.head range
  -                
  -            Array.tryFindIndex (fun tok -> 
  -                            let range = tokenToRange tok
  -                            predicate range) tokens
  -
  -        let tokNumberOption = findToken()
  -        if tokNumberOption.IsNone
  -        then 
  -            []
  -        else
  -            let token = new Terminal(tokNumberOption.Value)
  +            tokens
  +            |> Array.tryFindIndex predicate
  +
  +        let tokNumberOption = tryFindToken()
  +        match tokNumberOption with
  +        | None -> []
  +        | Some tokNumber ->
  +            let token = new Terminal(tokNumber)
               let forestFam = ref []
               let mutable forestTree = []
  -            let filter (family : Family) = 
  +            let filterFamily family = 
                   let nodes = Tree<_>.GetTokensFromFamily family
  -                if List.exists (fun tok -> tok = token) nodes
  +                if nodes |> List.exists ((=) token) 
                   then 
  -                    not <| List.exists (fun fam -> 
  +                    !forestFam 
  +                    |> List.forall (fun fam -> 
                                           let famNodes = Tree<_>.GetTokensFromFamily fam
  -                                        let newList = List.filter (fun node1 -> List.exists (fun node2 -> node1 = node2) famNodes) nodes
  +                                        let newList = List.filter (fun node1 -> List.exists ((=) node1) famNodes) nodes
                                           newList.Length = nodes.Length
  -                                    ) !forestFam 
  +                                    ) 
                   else false
   
               let filterTree (tree : Tree<_>) = 
                   match tree.Root with
                   | :? AST as ast -> 
                       // I suppose that rootFamily.other is always null. But I'm not sure
  -                    let res = filter ast.first
  +                    let res = filterFamily ast.first
                       if res then forestFam := ast.first :: !forestFam
                       res
  -                | x -> failwith "Error in GetForestWithToken function. Expected AST as tree.Root but %s was" <| x.GetType().ToString()
  -
  -            let mutable tree = fst <| this.GetNextTree [token] filter
  -
  +                | x -> failwithf "Error in GetForestWithToken function. Expected AST as tree.Root but %A was" <| x.GetType()
  +
  +            let mutable tree = fst <| this.GetNextTree [token] filterFamily
               while filterTree tree do
                   forestTree <- tree :: forestTree
  -                tree <- fst <| this.GetNextTree [token] filter
  +                tree <- fst <| this.GetNextTree [token] filterFamily
           
               forestTree
   
  
positive.code:         let nodeToNumber = new System.Collections.Hashtable({new Collections.IEqualityComparer with
                                                                      override this.Equals (x1, x2) = Object.ReferenceEquals (x1, x2)
                                                                      override this.GetHashCode x = x.GetHashCode()})
          use out = new System.IO.StreamWriter (path : string)
          out.WriteLine("digraph AST {")
  
          let createNode num isAmbiguous nodeType (str : string) =
  
negative.code:     /// <para> inputFilter is a function that is involved in choosing trees.</para>
      /// </summary>
      member this.GetNextTree (unprocessed : Terminal list) inputFilter = 
          let processedToks = Array.init tokens.Length (fun i -> unprocessed |> List.forall (fun j -> j.TokenNumber <> i))
          
          let processedFamily = new ResizeArray<_>()
  
          let filter family = 
              (not <| processedFamily.Contains family) && inputFilter family
  
          /// choose family from AST which contains the more unprocessed tokens.
          /// if filter returns 'false' for all families then ast.first will be returned. 
          let handleAST (ast : AST) = 
              if ast.other = null || Seq.forall ((<>) false) processedToks
              then 
                  ast.first
              else
                  /// intersects family tokens and unprocessed tokens
                  /// and returns length of the resulting list
                  let getUnprocessedCount family = 
                      let familyLeaves = 
                          Tree<_>.GetTokensFromFamily family 
                          |> Seq.distinct 
                          |> Seq.toList
                      unprocessed 
                      |> List.filter 
                          (
                              fun leaf -> 
                                  familyLeaves 
                                  |> List.exists (fun x -> x.TokenNumber = leaf.TokenNumber)
                          )
                      |> List.length
  
                  let nextFam = ref ast.first
                  let analyzeFamily = 
                      let maxNewToks = 
                          if filter ast.first 
                          then ref <| getUnprocessedCount ast.first
                          else ref -1
                      fun family -> 
                          let newTokens = getUnprocessedCount family
                          if newTokens > !maxNewToks 
                          then 
                              nextFam := family
                              maxNewToks := newTokens
                  
                  ast.other
                  |> Array.filter filter
                  |> Array.iter analyzeFamily
                  !nextFam
  
          let rec processFamily (family : Family) = 
              processedFamily.Add family
  