public double distanceSquared(Location o) {
        if (o == null) {
            throw new IllegalArgumentException("Cannot measure distance to a null location");
        } else if (o.getLevel() == null || getLevel() == null) {
            throw new IllegalArgumentException("Cannot measure distance to a null level");
        } else if (o.getLevel() != getLevel()) {
            throw new IllegalArgumentException("Cannot measure distance between " + getLevel().getName() + " and " + o.getLevel().getName());
        }

        return Math.pow(x - o.x, 2) + Math.pow(y - o.y, 2);
    }