private static boolean containsLegalAllGroup(Element p) {
    ComplexType t = p.getComplexType();
    if (!(t instanceof ComplexTypeComplexContent))
      return false;
    Particle particle = ((ComplexTypeComplexContent)t).getParticle();
    if (!(particle instanceof ParticleAll))
      return false;
    String ns = p.getName().getNamespaceUri();
    for (Particle child : ((ParticleAll)particle).getChildren()) {
      if (child instanceof ParticleRepeat) {
        Occurs occur = ((ParticleRepeat)child).getOccurs();
        if (occur.getMin() > 1 || occur.getMax() > 1)
          return false;
        child = ((ParticleRepeat)child).getChild();
      }
      if (!(child instanceof Element))
        return false;
      if (!((Element)child).getName().getNamespaceUri().equals(ns))
        return false;
    }
    return true;
  }