public Spinner getClosestOfSameType(Spinner a, boolean same) {
        Float min = null;
        Spinner closest = null;
        for (Spinner spinner : newSp) {
            if (spinner.getId() != a.getId()) {
                if (same) {
                    if (spinner.getType() == a.getType()) {
                        float newDistance = getDistance(spinner.getPosition(), a.getPosition());
                        if (min == null || newDistance < min) {
                            min = newDistance;
                            closest = spinner;
                        }
                    }
                } else {
                    if (spinner.getType() != a.getType()) {
                        float newDistance = getDistance(spinner.getPosition(), a.getPosition());
                        if (min == null || newDistance < min) {
                            min = newDistance;
                            closest = spinner;
                        }
                    }
                }
            }
        }
        return closest;
    }