code: public void removeElementsWithNoRelationships() {
          Set<RelationshipView> relationships = getRelationships();
  
          Set<String> elementIds = new HashSet<>();
          relationships.forEach(rv -> elementIds.add(rv.getRelationship().getSourceId()));
          relationships.forEach(rv -> elementIds.add(rv.getRelationship().getDestinationId()));
  
          for (ElementView elementView : getElements()) {
              if (!elementIds.contains(elementView.getId())) {
                  removeElement(elementView.getElement());
              }
          }
      }
docs: Removes all elements that have no relationships to other elements in this view.