@NotNull
  private static PyExpression invertExpression(@NotNull PyBinaryExpression expression, @NotNull PyElementGenerator elementGenerator) {
    if (isComparisonExpression(expression)) {
      final PyExpression left = expression.getLeftExpression();
      final PyExpression right = expression.getRightExpression();

      final String newOperator = invertOperator(Objects.requireNonNull(expression.getPsiOperator()));
      final PyExpression newRight = isComparisonExpression(left) ? invertExpression((PyBinaryExpression)left, elementGenerator) : left;

      return elementGenerator.createBinaryExpression(newOperator, right, newRight);
    }
    else {
      return expression;
    }
  }
@NotNull
  private static PyExpression invertExpression(@NotNull PyBinaryExpression expression, @NotNull PyElementGenerator elementGenerator)