### Question:
PatternMatch { public PatternMatch nth(int n, PatternMatch child) { return new PatternMatch(PatternType.PARENT_NTH, this, child, n); } private  PatternMatch(PatternType type, Object... args); @SuppressWarnings("unchecked") Map<String, CommonTree> match(CommonTree ct); static PatternMatch var(String name, PatternMatch p); static PatternMatch wild(); static PatternMatch kind(String k); static PatternMatch tuple(PatternMatch... tuple); PatternMatch child(PatternMatch child); PatternMatch nth(int n, PatternMatch child); static PatternMatch recursive(PatternMatch child); static PatternMatch or(PatternMatch... choice); static void replaceChildren(CommonTree dst, CommonTree src); static final Logger LOG; }### Answer:
@Test public void testNth() throws RecognitionException { CommonTree sink = FlumeBuilder.parseSink(simple); PatternMatch pp = kind("DECO").nth(1, kind("SINK").child(var("node", kind("logicalNode")))); Map<String, CommonTree> m = pp.match(sink); assertNotNull(m); assertEquals(m.get("node").getText(), "logicalNode"); dumpMatches(m); LOG.info(m); pp = kind("DECO").nth(0, kind("SINK").child(var("node", kind("logicalNode")))); m = pp.match(sink); assertNull(m); dumpMatches(m); LOG.info(m); }