private void deleteCollection(AbstractBluePrintsBackedFinderService<? extends Graph, ?, ?> service, Graph database, Property p, Object toDelete, Vertex objectVertex, Collection<CascadeType> toCascade, Map<String, Object> objectsBeingAccessed) {
Iterable<Edge> edges = service.getStrategy().getOutEdgesFor(objectVertex, p);
Collection<?> values = (Collection<?>) p.get(toDelete);
Map<Vertex, Edge> oldVertices = new HashMap<Vertex, Edge>();
for (Edge e : edges) {
Vertex inVertex = e.getVertex(Direction.IN);
oldVertices.put(inVertex, e);
}
for (Object v : values) {
// already heard about null-containing collections ? I do know them, and they're pure EVIL
if(v!=null) {
Vertex valueVertex = service.getVertexFor(v, CascadeType.REFRESH, objectsBeingAccessed);
if (valueVertex !=null && oldVertices.containsKey(valueVertex)) {
Edge oldEdge = oldVertices.remove(valueVertex);
GraphUtils.removeSafely(database, oldEdge);
if (toCascade.contains(CascadeType.REMOVE)) {
service.deleteOutEdgeVertex(objectVertex, valueVertex, v, objectsBeingAccessed);