@Test
public void testMultilevel() throws ParseError {
TemplateParser parser = new TemplateParser("!{(parent(parent(type=type1)) type=grandparent) | (parent type=type2 type=parent2) '{name}'}");
DatasetFactory ds = new DatasetFactory();
Relation parent1 = ds.addRelation(1);
parent1.put("type", "parent1");
parent1.put("name", "name_parent1");
Relation parent2 = ds.addRelation(2);
parent2.put("type", "parent2");
parent2.put("name", "name_parent2");
Node child1 = ds.addNode(1);
child1.put("type", "type1");
parent1.addMember(new RelationMember("", child1));
parent2.addMember(new RelationMember("", child1));
Node child2 = ds.addNode(2);
child2.put("type", "type2");
parent1.addMember(new RelationMember("", child2));
parent2.addMember(new RelationMember("", child2));
Relation grandParent = ds.addRelation(3);
grandParent.put("type", "grandparent");
grandParent.put("name", "grandparent_name");
grandParent.addMember(new RelationMember("", parent1));
StringBuilder sb = new StringBuilder();
TemplateEntry entry = parser.parse();
entry.appendText(sb, child1);