Delete all nodes related to a certain node

afbeelding
So when i remove the grey node, the green, pink and darkgreen nodes will be deleted as well.

I tried:
session.delete(thisnode.class, id, 5)

And a cypher solution is fine too, this didnt work either:
MATCH (n:thisnode)--(e) DETACH DELETE n,e;

What worked for me so far is:
MATCH path = (:thisnode)--()--()--() DETACH DELETE path

Try this:

MATCH (n:thisnode)-[r:HAS_SITUATION]-(b)
DELETE  r
DETACH DELETE n

This only deletes the 'thisnode' node and the 'has_situation' relation.

I would like to delete all of the nodes related to the grey 'thisnode', that includes the pink and darkgreen nodes and relations as well.

This query works for me:
MATCH path = (:thisnode)--()--()--() DETACH DELETE path
Where the first '--()' selects all lightgreen nodes with any relation to the grey one, the second '--()' all pink nodes with any relation to any of the nodes that have any relation to the grey node.
This solution is not dynamic at all since i need to specify the depth of what nodes need to be deleted by adding a bunch of '--()'.

Idealy i would be able to remove all of the nodes in the picture above with a simple dynamic query regardless of the relation depth. (but not all of the nodes in the database, its not a fully connected graph)

Try this:

MATCH (n:thisnode)
CALL apoc.path.spanningTree(n,{maxLevel:3}) YIELD path
RETURN path 

Use RETURN path to check the results, then you can use DETACH DELETE path

Change the maxLevel number according to your needs.