private static void pushIndexIfGreaterGradient(int width, int height, float currentGradient, int x, int y, float[] gradient, LinkedList<Integer> indexes,
                                                   final Set<Integer> indexes2) {
        if (x > -1 && x < width && y > -1 && y < height) {
            int nextIndex = x + y * width;
            if (gradient[nextIndex] < currentGradient) {
                return;
            }
            if (indexes2.contains(nextIndex) || indexes.contains(nextIndex)) {
                return;
            }
            indexes.push(nextIndex);
            indexes2.add(nextIndex);
        }
    }