recursive queries with conditional exiting in cypher

I am using python driver for neo4j to load a trie as a graph into the database. I have to write queries to perform search for prefixes of longest match, find substrings that are full words, the usual trie methods. How to write cypher queries that check for presence of flags (end of a word marker for example) in each node and take actions based on that. is there a way to write such a procedural queries in cypher. I know of traversal framework in java, but I am stuck with python. thanks in advance

Hi,

I'm not sure I have fully understand what you want to do but I suggest you to do the sorting and cleaning in python rather than in Cypher. It will be easier that way