def check_if_relationship_exists(txn, parent_node_id, tree_id, relationship):
    """Checks for existing relationships between nodes."""
    query = """
    MATCH (a)
    WHERE a.identifier = {parent_node_id} AND
          a.tree_id = "{tree_id}" AND
          (a)-[:{relationship}]->()
    RETURN a
    """.format(parent_node_id=parent_node_id,
               relationship=relationship,
               tree_id=tree_id)
    result = txn.run(query)
    if result.value():
        return True
    return False