@Override
	public Regex visitChoiceRegex(ChoiceRegex bean)
	throws RuntimeException
	{
		if(bean.getSubexps().size() == 1) return bean.getSubexps().get(0);
		
		ChoiceRegex rv = new ChoiceRegex();
		CharacterSetRegex chars = null;
		
		for(Regex subexp : bean.getSubexps())
		{
			Regex subexpS = subexp.acceptVisitor(this);
			if(subexpS instanceof CharacterSetRegex)
			{
				if(chars == null) chars = (CharacterSetRegex) subexpS;
				else chars = CharacterSetRegex.union(chars,(CharacterSetRegex) subexpS);
			}
			else if(subexpS instanceof ChoiceRegex)
			{
				rv.addSubexps(((ChoiceRegex) subexpS).getSubexps());
			}
			else rv.addSubexp(subexpS);
		}
		if(chars != null) rv.addSubexp(chars);

		if(rv.getSubexps().size() == 1) return rv.getSubexps().get(0);
		else return rv;
	}