private void removeExistingEntries() throws OSFileAssociationException {
    PListBuddyWrapper buddy = new PListBuddyWrapper();
    Document handlers = buddy.readData("LSHandlers");
    Node arrayNode = getTopArrayNode(handlers);
    List<Integer> entriesToRemove = new ArrayList<>();
    if (arrayNode != null) {
      Node[] entries = getEntries(arrayNode);
      for (int i = 0; i < entries.length; i ++) {
        String uri = extractUri(entries[i]);
        if (myUriSet.contains(uri)) {
          entriesToRemove.add(i);
        }
      }
    }
    if (!entriesToRemove.isEmpty()) {
      Collections.reverse(entriesToRemove); // Start from the last
      for (Integer index : entriesToRemove) {
        CommandResult result = buddy.runCommand("Delete LSHandlers:" + index);
        if (result.retCode != 0) {
          LOG.warn("PListBuddy returned: " + result.retCode + " for index " + index);
          throw new OSFileAssociationException(UPDATE_FAILURE_MSG);
        }
      }
    }
  }
private void removeExistingEntries()