protected virtual GrammarAST FindFirstTypeOutsideRewrite(GrammarAST block, BitSet types)
{
List<GrammarAST> worklist = new List<GrammarAST>();
worklist.Add(block);
while (worklist.Count > 0)
{
GrammarAST current = worklist[worklist.Count - 1];
worklist.RemoveAt(worklist.Count - 1);
if (current.Type == ANTLRParser.REWRITE)
continue;
if (current.Type >= 0 && types.Contains(current.Type))
return current;
worklist.AddRange(current.GetChildrenAsArray());
}
return null;
}