code: function(state) {
        if (isDefined(state.parent) && state.parent) return findState(state.parent);
        // regex matches any valid composite state name
        // would match "contact.list" but not "contacts"
        var compositeName = /^(.+)\.[^.]+$/.exec(state.name);
        return compositeName ? findState(compositeName[1]) : root;
      }
docs: Derive parent state from a hierarchical name only if 'parent' is not explicitly defined. state.children = []; if (parent) parent.children.push(state);