def getRelativeFreePlaceIndexForCoordinate(freePlaceMap, x, y):
    """
    Returns the Index in the FreePlaceValueArray in witch the given Coordinate is in
    :param freePlaceMap: The FreePlaceMap to check on
    :param x: The X Coordinate to Check for
    :param y: The Y Coordinate to Check for
    :return: The found Index or None if not Found
    """
    if freePlaceMap is None or len(freePlaceMap) < y or len(freePlaceMap[0]) < x or x < 0 or y < 0:
        return None
    # Check current Cell
    if freePlaceMap[y][x] != -1:
        return freePlaceMap[y][x] - 1
    # Check Left Cell
    elif x > 0 and freePlaceMap[y][x - 1] != -1:
        return freePlaceMap[y][x - 1] - 1
    # Check Right Cell
    elif x < len(freePlaceMap[0]) - 1 and freePlaceMap[y][x + 1] != -1:
        return freePlaceMap[y][x + 1] - 1
    # Check Cell Underneath
    elif y > 0 and freePlaceMap[y - 1][x] != -1:
        return freePlaceMap[y - 1][x] - 1
    # Check Upper Cell
    elif y < len(freePlaceMap) - 1 and freePlaceMap[y + 1][x] != -1:
        return freePlaceMap[y + 1][x] - 1
    return None