private static XmlFilter<Element> createFilter( Element root, String tag, boolean required ) throws IOException
   {
      XmlFilter<Element> filter = new XmlFilter<Element>( root.getElementsByTagName( tag ), Node.ELEMENT_NODE );

      if (required && !filter.hasNext())
      {
         throw new IOException( "Tag " + tag + " was expected and not found." );
      }

      return filter;
   }