code: public function deleteChilds($table, $id, &$delete)
  	{
  		$cctable = array();
  		$ctable = $GLOBALS['TL_DCA'][$table]['config']['ctable'];
  
  		if (!\is_array($ctable))
  		{
  			return;
  		}
  
  		// Walk through each child table
  		foreach ($ctable as $v)
  		{
  			$this->loadDataContainer($v);
  			$cctable[$v] = $GLOBALS['TL_DCA'][$v]['config']['ctable'];
  
  			// Consider the dynamic parent table (see #4867)
  			if ($GLOBALS['TL_DCA'][$v]['config']['dynamicPtable'])
  			{
  				$ptable = $GLOBALS['TL_DCA'][$v]['config']['ptable'];
  				$cond = ($ptable == 'tl_article') ? "(ptable=? OR ptable='')" : "ptable=?";
  
  				$objDelete = $this->Database->prepare("SELECT id FROM $v WHERE pid=? AND $cond")
  											->execute($id, $ptable);
  			}
  			else
  			{
  				$objDelete = $this->Database->prepare("SELECT id FROM $v WHERE pid=?")
  											->execute($id);
  			}
  
  			if (!$GLOBALS['TL_DCA'][$v]['config']['doNotDeleteRecords'] && \strlen($v) && $objDelete->numRows)
  			{
  				foreach ($objDelete->fetchAllAssoc() as $row)
  				{
  					$delete[$v][] = $row['id'];
  
  					if (!empty($cctable[$v]))
  					{
  						$this->deleteChilds($v, $row['id'], $delete);
  					}
  				}
  			}
  		}
  	}
docs: Recursively get all related table names and records
  
  @param string  $table
  @param integer $id
  @param array   $delete