protected function markingFinished($numChildrenMethod="numChildren") {
        // Mark childless nodes as expanded.
        if($this->markedNodes) {
            foreach($this->markedNodes as $id => $node) {
                if(!$node->isExpanded() && !$node->$numChildrenMethod()) {
                    $node->markExpanded();
                }
            }
        }
    }