code: public void insert(final Parse constituent) {
      Span ic = constituent.span;
      if (span.contains(ic)) {
        //double oprob=c.prob;
        int pi=0;
        int pn = parts.size();
        for (; pi < pn; pi++) {
          Parse subPart = (Parse) parts.get(pi);
          //System.err.println("Parse.insert:con="+constituent+" sp["+pi+"] "+subPart+" "+subPart.getType());
          Span sp = subPart.span;
          if (sp.getStart() >= ic.getEnd()) {
            break;
          }
          // constituent contains subPart
          else if (ic.contains(sp)) {
            //System.err.println("Parse.insert:con contains subPart");
            parts.remove(pi);
            pi--;
            constituent.parts.add(subPart);
            subPart.setParent(constituent);
            //System.err.println("Parse.insert: "+subPart.hashCode()+" -> "+subPart.getParent().hashCode());
            pn = parts.size();
          }
          else if (sp.contains(ic)) {
            //System.err.println("Parse.insert:subPart contains con");
            subPart.insert(constituent);
            return;
          }
        }
        //System.err.println("Parse.insert:adding con="+constituent+" to "+this);
        parts.add(pi, constituent);
        constituent.setParent(this);
        //System.err.println("Parse.insert: "+constituent.hashCode()+" -> "+constituent.getParent().hashCode());
      }
      else {
        throw (new InternalError("Inserting constituent not contained in the sentence!"));
      }
    }
docs: Inserts the specified constituent into this parse based on its text span.  This
  method assumes that the specified constituent can be inserted into this parse.
  @param constituent The constituent to be inserted.