private NodeState compact() {
        if (state.isEmpty() && children.isEmpty()) {
            if (parent != null) {
                return parent.removeChild(id);
            }
        }
        return this;
    }
Compacts the system state tree from this node upwards. This will delete itself if it has a parent, but no
internal state and no children.

@return This or the first non-null ancestor, to allow chaining.
documentapi/src/main/java/com/yahoo/documentapi/messagebus/systemstate/rule/NodeState.java