private boolean containsState(LockPieceState newState) {
    if (newState.ADown) {
      newState.ADown = false;
      if (containsState(newState)) {
        newState.ADown = true;
        return true;
      }
      newState.ADown = true;
    }
    if (newState.BDown) {
      newState.BDown = false;
      if (containsState(newState)) {
        newState.BDown = true;
        return true;
      }
      newState.BDown = true;
    }
    if (newState.leftDown) {
      newState.leftDown = false;
      if (containsState(newState)) {
        newState.leftDown = true;
        return true;
      }
      newState.leftDown = true;
    }
    if (newState.rightDown) {
      newState.rightDown = false;
      if (containsState(newState)) {
        newState.rightDown = true;
        return true;
      }
      newState.rightDown = true;
    }
    return stateDistMap.containsKey(newState);
  }