{
        int count = 0;
        for (InternalEObject parent = ((InternalEObject)eObject).eInternalContainer(); parent != null; parent = parent.eInternalContainer())
        {
          if (++count > 100000)
          {
            return getRootContainer(parent, false);
          }
          result = parent;
          if (parent == eObject)
          {
            throw new IllegalStateException("There is a cycle in the containment hierarchy of " + eObject);
          }
        }
      }