@param bool $is_nested_in_repeat true if any parent element has tal:repeat

@return rough guess
439743
private function estimateNumberOfBytesOutput(PHPTAL_Dom_Element $element, $is_nested_in_repeat)
    {
        // macros don't output anything on their own
        if ($element->hasAttributeNS('http://xml.zope.org/namespaces/metal', 'define-macro')) {
            return 0;
        }

        $estimated_bytes = 2*(3+strlen($element->getQualifiedName()));

        foreach ($element->getAttributeNodes() as $attr) {
            $estimated_bytes += 4+strlen($attr->getQualifiedName());
            if ($attr->getReplacedState() === PHPTAL_Dom_Attr::NOT_REPLACED) {
                $estimated_bytes += strlen($attr->getValueEscaped()); // this is shoddy for replaced attributes
            }
        }

        $has_repeat_attr = $element->hasAttributeNS('http://xml.zope.org/namespaces/tal', 'repeat');

        if ($element->hasAttributeNS('http://xml.zope.org/namespaces/tal', 'content') ||
            $element->hasAttributeNS('http://xml.zope.org/namespaces/tal', 'replace')) {
            // assume that output in loops is shorter (e.g. table rows) than outside (main content)
            $estimated_bytes += ($has_repeat_attr || $is_nested_in_repeat) ? 500 : 2000;
        } else {
            foreach ($element->childNodes as $node) {
                if ($node instanceof PHPTAL_Dom_Element) {
                    $estimated_bytes += $this->estimateNumberOfBytesOutput($node, $has_repeat_attr || $is_nested_in_repeat);
                } else {
                    $estimated_bytes += strlen($node->getValueEscaped());
                }
            }
        }

        if ($element->hasAttributeNS('http://xml.zope.org/namespaces/metal', 'use-macro')) {
            $estimated_bytes += ($has_repeat_attr || $is_nested_in_repeat) ? 500 : 2000;
        }

        if ($element->hasAttributeNS('http://xml.zope.org/namespaces/tal', 'condition')) {
            $estimated_bytes /= 2; // naively assuming 50% chance, that works well with if/else pattern
        }

        if ($element->hasAttributeNS('http://xml.zope.org/namespaces/tal', 'repeat')) {
            // assume people don't write big nested loops
            $estimated_bytes *= $is_nested_in_repeat ? 5 : 10;
        }

        return $estimated_bytes;
    }
430612
public function isTethered(): bool
    {
        $parent = $this->getParent();
        if ($parent === null) {
            return false;
        }
        if (array_key_exists($this->getName(), $parent->getNodeType()->getAutoCreatedChildNodes())) {
            return true;
        }

        return false;
    }
316202
public function hasChilds($idParent)
    {
        if ($numOfChilds = $this->getNumOfChilds($idParent)) {
            return (bool)($numOfChilds == 0 ? false : true);
        }

        return false;
    }
883638
function contains($item, callable $callback = null) {
        if ($callback === null) {
            $callback = __NAMESPACE__ . '\\compare';
        }
        foreach ($this->avl as $pair) {
            /**
             * @var Pair $pair
             */
            if (call_user_func($callback, $pair->second, $item) === 0) {
                return true;
            }
        }

        return false;
    }
346085
public function hasSharedParent()
    {
        $parent = $this->getParent();

        if ($parent != null && ($parent->isShared() || $parent->hasSharedParent())) {
            return true;
        }

        return false;
    }
27496
protected function grouped_parent_exists($path) {
        // Search the tree structure to find out if one of the paths
        // above the $path is a grouped path.
        $patharray = explode('/', $this->get_parent_path($path));
        $groupedpath = '';
        $currentpos = &$this->groupedparentprefixtree;
        foreach ($patharray as $item) {
            // When the item isn't set in the array we know
            // there is no parent grouped path.
            if (!isset($currentpos[$item])) {
                return false;
            }

            // When we aren't at the start of the path, continue to build
            // a string representation of the path that is traversed.  We will
            // return the grouped path to the caller if we find one.
            if ($item != '') {
                $groupedpath .= '/'.$item;
            }

            if ($currentpos[$item] == array()) {
                return $groupedpath;
            }
            $currentpos = &$currentpos[$item];
        }
        return false;
    }
1262816
def is_nested_object(obj):
    

    if isinstance(obj, ABCSeries) and is_object_dtype(obj):

        if any(isinstance(v, ABCSeries) for v in obj.values):
            return True

    return False
1066716
def _sanity_check_no_nested_folds(ir_blocks):
    """"""
    fold_seen = False
    for block in ir_blocks:
        if isinstance(block, Fold):
            if fold_seen:
                raise AssertionError(u'Found a nested Fold contexts: {}'.format(ir_blocks))
            else:
                fold_seen = True
        elif isinstance(block, Unfold):
            if not fold_seen:
                raise AssertionError(u'Found an Unfold block without a matching Fold: '
                                     u'{}'.format(ir_blocks))
            else:
                fold_seen = False
1192060
public static function array_next_element($arr, $nested_key, $iteration = 1)
    {
        foreach ($arr as $key => $v) {
            current($arr);

            if ($key == $nested_key) {
                for ($i = 0; $i < $iteration; $i++) {
                    $return = next($arr);
                }

                if (!empty($return)) {
                    return $return;
                } else {
                    return false;
                }
            }

            next($arr);
        }

        return false;
    }
21002
public function hasSingleChildBlockElement()
    {
        $result = false;
        if ($this->hasChildNodes()) {
            foreach ($this->getChildren() as $child) {
                if (in_array($child->nodeName, $this->divToPElements)) {
                    $result = true;
                } else {
                    // If any of the hasSingleChildBlockElement calls return true, return true then.
                    /** @var $child DOMElement */
                    $result = ($result || $child->hasSingleChildBlockElement());
                }
            }
        }

        return $result;
    }
497339
public function requireOccurrenceRegeneration($repetitions1, $repetitions2)
    {
        if (count($repetitions1) != count($repetitions2)) {
            return true;
        }

        $comparator = new Comparator();

        for ($i = 0; $i < count($repetitions1); $i++) {
            if (!$comparator->areEqual($repetitions1[$i]->getRepetitionObject(), $repetitions2[$i]->getRepetitionObject())) {
                return true;
            }
        }

        return false;
    }
769830
function isChild(child, parent) {
	while (child = child.parentNode) {
		if (child == parent) {
			return true;
		}
	}

	return false;
}
333893
def _match_parent(self, match, yield_parent):
        
        ret = super(Chain, self)._match_parent(match, yield_parent)
        original_children = Matches(match.children)
        original_end = match.end
        while not ret and match.children:
            last_pattern = match.children[-1].pattern
            last_pattern_children = [child for child in match.children if child.pattern == last_pattern]
            last_pattern_groups_iter = itertools.groupby(last_pattern_children, lambda child: child.match_index)
            last_pattern_groups = {}
            for index, matches in last_pattern_groups_iter:
                last_pattern_groups[index] = list(matches)

            for index in reversed(list(last_pattern_groups)):
                last_matches = list(last_pattern_groups[index])
                for last_match in last_matches:
                    match.children.remove(last_match)
                match.end = match.children[-1].end if match.children else match.start
                ret = super(Chain, self)._match_parent(match, yield_parent)
                if ret:
                    return True
        match.children = original_children
        match.end = original_end
        return ret
856136
private static boolean parentExists(Resource res) {
	res = res.getParentResource();
	return res != null && res.exists();
    }
193442
public function isSummaryShown($isFirst = false, $isMiddle = false, $isLast = false)
    {
        return $this->isShown('Summary', $isFirst, $isMiddle, $isLast);
    }
764418
function contains(parent, child) {
		if (!parent || !child) { return false; }
		if (parent === child) { return true; }
		var compare = parent.compareDocumentPosition(child);  // useful to break out for debugging
		return Boolean(compare & 16);
	}
108967
public function __isset($attr)
    {
        if ($attr === 'name') {
            return $this->firstSetNameLocale() === null ? false : true;
        }

        return parent::__isset($attr);
    }