TiledMapTileSet.Tiles.Count not same as TiledMapTileSet.TileCount

I’m trying to create a function that gets the local tile from its tileset, given the tile from a layer.

public static TiledMapTilesetTile GetTile(this TiledMapTile tile, TiledMap tiledMap)
{
	TiledMapTileset tileset = tiledMap.GetTilesetByTileGlobalIdentifier(tile.GlobalIdentifier);
	int FID = tiledMap.GetTilesetFirstGlobalIdentifier(tileset);
	int GID = tile.GlobalIdentifier;
	int LID = GID - FID;
	int count = tileset.TileCount;
	return tileset.Tiles.ElementAt(LID);
}

The problem is that the TiledMapTileSet.Tiles collection is often smaller than the real tileset size, which TiledMapTileSet.TileCount displays correctly. So I’m basically always going out of bounds getting the tile using tileset.Tiles.ElementAt(LID) even though the LID value is correct.