   Messages._ensureIndex [
     ['group', 1]
     ['updated', -1]
+  ]
+  ## This index makes findMessageParent fast.
+  Messages._ensureIndex [
+    ['children', 1]
   ]
 
 @rootMessages = (group) ->

  check position, Number if position?
  #check oldParent, Boolean
  #check importing, Boolean
  if parent?
    pmsg = Messages.findOne parent
    unless pmsg
      console.warn 'Missing parent', parent, 'for child', child
      return  ## This should only happen in client simulation
    group = pmsg.group
    root = pmsg.root ? parent

    ## Check before creating a cycle in the parent pointers!
    ancestor = pmsg
    while ancestor?
      if ancestor._id == child
        throw new Meteor.Error 'messageParent.cycle',
          "Attempt to make #{child} its own ancestor (via #{parent})"
      ancestor = findMessageParent ancestor
  else
    group = child.group  ## xxx can't specify other group...
    root = null

  unless canEdit(child) and canPost group, parent
    throw new Meteor.Error 'messageParent.unauthorized',
      "Insufficient privileges to reparent message #{child} into #{parent}"

  cmsg = Messages.findOne child
  oldPosition = null
  oldSiblingsBefore = null
  oldSiblingsAfter = null

      $set: root: root
    if cmsg.root?
      ## If we move a nonroot message to have new root, update descendants.
      descendants = descendantMessageIds cmsg
      if descendants.length > 0
        Messages.update
          _id: $in: descendants
