anchor.diff:      DiagTerKind: TKMTerrainKind;
       HasCornerTiles: Boolean;
       TerKinds: array [0..2] of TKMTerrainKind;
  +    cornersTerKinds: TKMTerrainKindCorners;
     begin
       Result := tkCustom;
       case aCorner of
  
positive.code: 
  var
    I,K,M: Integer;
    VertexTKinds: TKMTerrainKindsArray;
    SameTKind, NoCustomTK: Boolean;
    TKCounts, MostTKIs: array[0..3] of Integer;
    MostTKCnt, MostTKI, vrxCnt: Integer;
  begin
    Result := False;
    aEffectiveTKind := tkCustom;
  
    VertexTKinds := GetVertexCornerTerKinds(X,Y);
    vrxCnt := Length(VertexTKinds);
    SameTKind := True;
  
    Assert(vrxCnt > 0, 'Can''t find vertex corners');
  
    for K := 0 to vrxCnt - 1 do
    begin
      TKCounts[K] := 0;
      MostTKIs[K] := 0;
    end;
  
    //Find most popular TerKind
    //Count all TerKinds occurrences first
    for K := 0 to vrxCnt - 1 do
      for M := K + 1 to vrxCnt - 1 do
        if VertexTKinds[K] = VertexTKinds[M] then
          Inc(TKCounts[K]);
  
    //Get Most popular one index
    MostTKCnt := -1;
    I := 0;
    for K := 0 to vrxCnt - 1 do
      if TKCounts[K] > MostTKCnt then
      begin
        I := 0;
        MostTKIs[I] := K;
        MostTKCnt := TKCounts[K];
        Inc(I);
      end
      else
      if TKCounts[K] = MostTKCnt then
      begin
        MostTKIs[I] := K;
        Inc(I);
      end;
  
    MostTKI := MostTKIs[KaMRandom(I, 'TKMTerrainPainter.TryGetVertexEffectiveTerKind')];
  
    NoCustomTK := VertexTKinds[0] <> tkCustom;
    for K := 1 to vrxCnt - 1 do
    begin
      SameTKind := SameTKind and EqualTKinds(VertexTKinds[K], VertexTKinds[K-1]);
      NoCustomTK := NoCustomTK and (VertexTKinds[K] <> tkCustom);
    end;
  
    //Replace TerKind with most popular one if there all TerKinds are equal or if there is no custom TerKinds
    if SameTKind or NoCustomTK then
    begin
      aEffectiveTKind := VertexTKinds[MostTKI];
      Result := True;
    end;
  end;
  
negative.code:     TerKind := LandTerKind[aY,aX].TerKind;
      if TerKind <> tkCustom then
      begin
        terKindFound[aI] := True;
        aCornersTerKinds[aI] := TerKind;
      end;
    end;
  
  var
    I,L: Integer;
    tile: TKMTerrainTileBasic;
  
  begin
    Assert(not (aGetOnlyTileCornersTK and aGetOnlyLandNodeTK)); //At least 1 of those parameters should be False
  
    //Init with tkCustom
    for I := 0 to 3 do
    begin
      terKindFound[I] := False;
      aCornersTerKinds[I] := tkCustom;
    end;
  
    //Get tile corners TKinds based on LandTerKind
  