public function onNodePresave(NodeEvent $event)
    {
        $node = $event->getNode();

        // When coming from the node form, node form has already been submitted
        // case in which, if relevant, a group identifier has already been set
        // and this code won't be execute. In the other hand, if the prepare
        // hook has not been invoked, this will run and set things right.
        // There is still a use case where the node comes from the node form but
        // there is no contextual group, case in which this code will wrongly
        // run, but hopefuly since it is just setting defaults, it won't change
        // the normal behavior.
        if (empty($node->group_id)) {
            $groupId = $this->findMostRelevantGroupId();

            if ($groupId) {
                $node->group_id = $groupId;
            }

            $node->is_ghost = $this->findMostRelevantGhostValue($node);
        }
    }