anchor.diff:          if seenThisTycon && allowMultiIntfInst = AllowMultiIntfInstantiations.No then state else
   
           let state =
  -            if isAppTy g ty then
  -                let tcref = tcrefOfAppTy g ty
  +            match tryTcrefOfAppTy g ty with
  +            | ValueSome tcref ->
                   let visitedTycon = Set.add tcref.Stamp visitedTycon
                   visitedTycon, visited.Add (tcref, ty), acc
  -            else
  +            | _ ->
                   state
   
           if ndeep > 100 then (errorR(Error((FSComp.SR.recursiveClassHierarchy (showType ty)), m)); (visitedTycon, visited, acc)) else
  
positive.code: let private FoldHierarchyOfTypeAux followInterfaces allowMultiIntfInst skipUnref visitor g amap m ty acc =
      let rec loop ndeep ty ((visitedTycon, visited: TyconRefMultiMap<_>, acc) as state) =
  
          let seenThisTycon = isAppTy g ty && Set.contains (tcrefOfAppTy g ty).Stamp visitedTycon
  
          // Do not visit the same type twice. Could only be doing this if we've seen this tycon
          if seenThisTycon && List.exists (typeEquiv g ty) (visited.Find (tcrefOfAppTy g ty)) then state else
  
negative.code: 
  /// Check if two types have the same nominal head type
  let HaveSameHeadType g ty1 ty2 =
      match tryTcrefOfAppTy g ty1 with
      | ValueSome tcref1 ->
          match tryTcrefOfAppTy g ty2 with
          | ValueSome tcref2 -> tyconRefEq g tcref1 tcref2
          | _ -> false
      | _ -> false
  
  /// Check if a type has a particular head type
  let HasHeadType g tcref ty2 =
      match tryTcrefOfAppTy g ty2 with
      | ValueSome tcref2 -> tyconRefEq g tcref tcref2
      | ValueNone -> false
  
  /// Check if a type exists somewhere in the hierarchy which has the same head type as the given type (note, the given type need not have a head type at all)
  let ExistsSameHeadTypeInHierarchy g amap m typeToSearchFrom typeToLookFor =
  