This function cleans all old post parents without any child.
979775
def blog__clean_post_parents
      post_parents = LatoBlog::PostParent.all
      post_parents.map { |pp| pp.destroy if pp.posts.empty? }
    end
576763
public function clear()
    {
        $this->dom = null;
        $this->nodes = null;
        $this->parent = null;
        $this->children = null;
    }
91358
public void cleanUp() {
    m_Owner     = null;
    m_Train     = null;
    m_Test      = null;
    m_Generator = null;
    m_Values    = null;
  }
1129995
private void tidy() {
        nonPermanent.entrySet().stream()
                .map(entry -> {
                    List<WeakReference<IzouSoundLineBaseClass>> collect = entry.getValue().stream()
                            .filter(izouSoundLineWeakReference -> izouSoundLineWeakReference.get() != null)
                            .collect(Collectors.toList());
                    if (!collect.isEmpty()) {
                        nonPermanent.put(entry.getKey(), collect);
                        return null;
                    } else {
                        return entry;
                    }
                })
                .filter(Objects::nonNull)
                .forEach(entry -> nonPermanent.remove(entry.getKey()));
    }
1086117
def _clean_record(self, record):
        """"""
        for k, v in dict(record).items():
            if isinstance(v, dict):
                v = self._clean_record(v)
            if v is None:
                record.pop(k)
        return record
147563
public function removeAll()
    {
        foreach ($this->_associated_objects as $parent_property => $object) {
            /**
             * @var Model
             */
            $object->setDirty($parent_property);
        }
        $this->exchangeArray([]);
    }
1070208
function cleanChildren(array) {
    if (!Array.isArray(array)) {
        return array;
    }
    return array.map(function(el) {
        if (el.type == "#text") {
            return el.children;
        } else {
            return {
                type: el.type,
                props: el.props,
                children: cleanChildren(el.children),
            };
        }
    });
}
234676
def clean(self):
        
        super(CTENode, self).clean()
        if self.parent and self.pk in getattr(self.parent, self._cte_node_path):
            raise ValidationError(_("A node cannot be made a descendant of itself."))
890036
function cleanTree (oSymbol) {
			delete oSymbol.treeName;
			delete oSymbol.parent;
			if (oSymbol.children) {
				oSymbol.children.forEach(o => cleanTree(o));
			}
		}
1151265
private void _cleanChildren() {
        //bStatsTreeNeedsUpdate = true;
        if (children != null) {
            Iterator values = children.values().iterator();

            while (values.hasNext()) {
                ModuleItem remMI = (ModuleItem) values.next();
                remMI.getInstance().cleanup();

                //_cleanMBean(remMI);
                remMI._cleanChildren();
                remMI = null;
            }

            children.clear();
        }
    }
831304
public function flush()
    {
        $this->ancestorWithFontSize = null;
        $this->ancestorWithRotation = null;
        $this->closestAncestorWithPosition = null;

        foreach($this->getChildren() as $child)
        {
            $child->flush();
        }

        $this->removeAll();
    }
795720
def clean(self):
        
        self.exec_pg_success(['dropdb', '-U', self.user, self.database])
        self.exec_pg_success(['createdb', '-U', self.user, self.database])
542502
protected function clearEntireListParentHierarchy()
    {
        $separator = $this->getListParentSeparator();

        foreach ($this->listParents as $parent) {

            if ( ! $parent || is_string($parent) && false === strpos($parent, $separator)) {
                break;
            }

            // Unset parent at this level
            $context = $this->getModelSessionKey(
                $this->getModuleHelper()->modelSlug(get_class($parent->model))
            );

            $this->setListParentDataInMemory(null, null, $parent->relation . $separator . $parent->key, $context);
        }

        $this->setListParentDataInMemory(null, null, $this->globalSubContext());

        $this->listParentRelation  = null;
        $this->listParentRecordKey = null;
        $this->listParents         = [];
    }
460003
public function clean()
    {
        $allchild = $this->getChildComponents(true);
        foreach ($allchild as $component) {
            
            if($component instanceof SubmitDataRequest) {
               $component->clean();
            }
         
 
        }
    }
600225
function _removeParentsIfEmpty(node) {
  let currentNode = node.parent;
  node.remove();
  while (!currentNode.nodes.length) {
    const { parent } = currentNode;
    currentNode.remove();
    currentNode = parent;
  }
}
790269
def clean(self):
        
        logger.info('Cleaning up archive')
        shutil.move(
            os.path.join(
                self.data_dir,
                'var/IRS/data/scripts/pofd/download/FullDataFile.txt'
            ),
            self.final_path
        )

        shutil.rmtree(os.path.join(self.data_dir, 'var'))
        os.remove(self.zip_path)
1017809
def clean():
        
        shutil.rmtree(BUILD_PATH, ignore_errors=True)
        shutil.rmtree(os.path.join(SOURCE_PATH, 'reference', 'api'),
                      ignore_errors=True)