protected function removeSubtree($id, $action, $original)
{
// Remove first to avoid unnecessary recursion.
if ($original) {
// If entry is original remove all for action (history and custom entries included).
$this->gateway->remove($action);
} else {
// Else entry is history, so remove only for action with the id.
// This means $id grouped history entries are removed, other history, active autogenerated
// and custom are left alone.
$this->gateway->remove($action, $id);
}
// Load all autogenerated for parent $id, including history.
$entries = $this->gateway->loadAutogeneratedEntries($id, true);
foreach ($entries as $entry) {
$this->removeSubtree($entry['id'], $entry['action'], $entry['is_original']);
}
}