public static HashSet<Ball> findCollisions(ArrayList<Ball> ballList)
	{
		// Set of all collisions.
		HashSet<Ball> collisions = new HashSet<Ball>();
				
		if(!ballList.isEmpty())
		{
			// We sort by X coordinate ascending.
			Collections.sort(ballList, Comparator.comparing(Ball::getX));
			
			// check each ball against the next one until ball j - ball i is larger than ball j diameter.
			for(int i = 0; i < ballList.size() - 1; ++i)
			{
				for(int j = i + 1; j < ballList.size() && ballList.get(j).getX() - ballList.get(i).getX() < ballList.get(i).getBallSize(); ++j)
				{
					// check if the ball is within y range.
					if(Math.abs(ballList.get(i).getY() - ballList.get(j).getY()) < ballList.get(i).getBallSize())
						if(checkCollision(ballList.get(i), ballList.get(j)))
						{
							collisions.add(ballList.get(i));
							collisions.add(ballList.get(j));
							
							if(ballList.get(j).willKill() || ballList.get(i).willKill())
							{
								ballList.get(j).setAlive(false);
								ballList.get(i).setAlive(false);
							}
						}
				}
			}
		}
		
		return collisions;
	}