code: protected final Stack<Long> addNewElement(final Stack<Long> paramLeftSiblingKeyStack,
          final StartElement paramEvent) throws TTException {
          assert paramLeftSiblingKeyStack != null && paramEvent != null;
          long key;
  
          final QName name = paramEvent.getName();
  
          if (mFirstChildAppend == EShredderInsert.ADDASRIGHTSIBLING) {
              checkState(mWtx.getNode().getKind() != IConstants.ROOT,
                  "Subtree can not be inserted as sibling of Root");
              key = mWtx.insertElementAsRightSibling(name);
              mFirstChildAppend = EShredderInsert.ADDASFIRSTCHILD;
          } else {
              if (paramLeftSiblingKeyStack.peek() == NULL_NODE) {
                  key = mWtx.insertElementAsFirstChild(name);
              } else {
                  key = mWtx.insertElementAsRightSibling(name);
              }
          }
  
          paramLeftSiblingKeyStack.pop();
          paramLeftSiblingKeyStack.push(key);
          paramLeftSiblingKeyStack.push(NULL_NODE);
  
          // Parse namespaces.
          for (final Iterator<?> it = paramEvent.getNamespaces(); it.hasNext();) {
              final Namespace namespace = (Namespace)it.next();
              mWtx.insertNamespace(new QName(namespace.getNamespaceURI(), "", namespace.getPrefix()));
              mWtx.moveTo(key);
          }
  
          // Parse attributes.
          for (final Iterator<?> it = paramEvent.getAttributes(); it.hasNext();) {
              final Attribute attribute = (Attribute)it.next();
              mWtx.insertAttribute(attribute.getName(), attribute.getValue());
              mWtx.moveTo(key);
          }
          return paramLeftSiblingKeyStack;
      }
docs: Add a new element node.
  
  @param paramLeftSiblingKeyStack
  stack used to determine if the new element has to be inserted
  as a right sibling or as a new child (in the latter case is
  NULL on top of the stack)
  @param paramEvent
  the current event from the StAX parser
  @return the modified stack
  @throws TTException
  if adding {@link ElementNode} fails