public function removeLastSibling($first_node_id) { if (!$this->hasIdentifier($first_node_id)) { throw new e\NodeException(S_SPAN . "The node {$first_node_id} does not exist." . E_SPAN); } $first_node = $this->node_map[$first_node_id]; $field_id = StructuredDataNode::getFieldIdentifier($first_node_id); // non-ambiguous path, no multiple ancestor if (strpos($first_node_id, $field_id) !== false) { return $this->removeLastNodeFromField($field_id); } // with multiple ancestor $parent_id = $first_node->getParentId(); $parent_node = $this->node_map[$parent_id]; if (self::DEBUG) { u\DebugUtility::out("Parent ID: " . $parent_id); } $shared_id = StructuredDataNode::removeLastIndex($first_node_id); if (self::DEBUG) { u\DebugUtility::out("Shared ID: " . $shared_id); } $shared_id = StructuredDataNode::removeLastIndex($first_node_id); $parent_node->removeLastChildNode($shared_id); $this->identifiers = array_keys($this->node_map); return $this; }