Get the first toplevel widget in a Gtk.Builder hierarchy.

    This is mostly used for guessing purposes, and an explicit naming is
    always going to be a better situation.
10286
def get_first_builder_window(builder):
    
    for obj in builder.get_objects():
        if isinstance(obj, Gtk.Window):
            # first window
            return obj
280511
@Override
    public Tree getAncestor(int ttype) {
        Tree t = this;
        t = t.getParent();
        while ( t!=null ) {
            if ( t.getType()==ttype ) return t;
            t = t.getParent();
        }
        return null;
    }
1346430
def _toplevel(cls):
        
        superclasses = (
            list(set(ClosureModel.__subclasses__()) &
                 set(cls._meta.get_parent_list()))
        )
        return next(iter(superclasses)) if superclasses else cls
1134920
private NodeBuilder ascend()
    {
        ensureParent();
        boolean isLeaf = isLeaf(copyFrom);
        if (buildKeyPosition > FAN_FACTOR)
        {
            // split current node and move the midpoint into parent, with the two halves as children
            int mid = buildKeyPosition / 2;
            parent.addExtraChild(buildFromRange(0, mid, isLeaf, true), buildKeys[mid]);
            parent.finishChild(buildFromRange(mid + 1, buildKeyPosition - (mid + 1), isLeaf, false));
        }
        else
        {
            parent.finishChild(buildFromRange(0, buildKeyPosition, isLeaf, false));
        }
        return parent;
    }
434231
def top_level(self):
        
        top = list(self.cell_dict.values())
        for cell in self.cell_dict.values():
            for dependency in cell.get_dependencies():
                if dependency in top:
                    top.remove(dependency)
        return top
279515
function topLevelItems(root) {
            var topLevel = [];
            function recur(item) {
                if (isTopLevel(item)) {
                    topLevel.push(item);
                    if (item.children) {
                        for (var _i = 0, _a = item.children; _i < _a.length; _i++) {
                            var child = _a[_i];
                            recur(child);
                        }
                    }
                }
            }
            recur(root);
            return topLevel;
            function isTopLevel(item) {
                switch (navigationBarNodeKind(item)) {
                    case 221 /* ClassDeclaration */:
                    case 192 /* ClassExpression */:
                    case 224 /* EnumDeclaration */:
                    case 222 /* InterfaceDeclaration */:
                    case 225 /* ModuleDeclaration */:
                    case 256 /* SourceFile */:
                    case 223 /* TypeAliasDeclaration */:
                    case 279 /* JSDocTypedefTag */:
                        return true;
                    case 148 /* Constructor */:
                    case 147 /* MethodDeclaration */:
                    case 149 /* GetAccessor */:
                    case 150 /* SetAccessor */:
                        return hasSomeImportantChild(item);
                    case 180 /* ArrowFunction */:
                    case 220 /* FunctionDeclaration */:
                    case 179 /* FunctionExpression */:
                        return isTopLevelFunctionDeclaration(item);
                    default:
                        return false;
                }
                function isTopLevelFunctionDeclaration(item) {
                    if (!item.node.body) {
                        return false;
                    }
                    switch (navigationBarNodeKind(item.parent)) {
                        case 226 /* ModuleBlock */:
                        case 256 /* SourceFile */:
                        case 147 /* MethodDeclaration */:
                        case 148 /* Constructor */:
                            return true;
                        default:
                            return hasSomeImportantChild(item);
                    }
                }
                function hasSomeImportantChild(item) {
                    return ts.forEach(item.children, function (child) {
                        var childKind = navigationBarNodeKind(child);
                        return childKind !== 218 /* VariableDeclaration */ && childKind !== 169 /* BindingElement */;
                    });
                }
            }
        }
1106164
public BaseFunction getBuiltinCtor(Builtins type) {
        return ctors != null ? ctors.get(type) : null;
    }
1196866
def find_top_level_directory(start_directory):
    
    top_level = start_directory
    while os.path.isfile(os.path.join(top_level, '__init__.py')):
        top_level = os.path.dirname(top_level)
        if top_level == os.path.dirname(top_level):
            raise ValueError("Can't find top level directory")
    return os.path.abspath(top_level)
889705
function topLevelNodeAt(node, top) {
    while (node && node.parentNode != top)
      node = node.parentNode;
    return node;
  }
1253888
public Class<? extends ElementBase> getRootClass() {
        LayoutElement top = root == null ? null : root.getChild(LayoutElement.class);
        return top == null ? null : top.getDefinition().getClazz();
    }
232848
def top_level(self):
        
        output = {}
        if isinstance(self.obj, dict):
            for name, item in self.obj.items():
                if isinstance(item, dict):
                    if item:
                        output[name] = StrReprWrapper('{...}')
                    else:
                        output[name] = StrReprWrapper('{}')
                elif isinstance(item, list):
                    if item:
                        output[name] = StrReprWrapper('[...]')
                    else:
                        output[name] = StrReprWrapper('[]')
                else:
                    output[name] = item
            return output
        else:
            return self.obj
399881
def topWindow():
    
    import_qt(globals())
    
    window = QtGui.QApplication.instance().activeWindow()
    if not window:
        return None
    
    parent = window.parent()
    
    while parent:
        window = parent
        parent = window.parent()
        
    return window
603709
public static Scriptable getTopLevelScope(Scriptable obj)
    {
        for (;;) {
            Scriptable parent = obj.getParentScope();
            if (parent == null) {
                return obj;
            }
            obj = parent;
        }
    }
171124
def init_widget(self):
        
        super(UiKitSlider, self).init_widget()

        d = self.declaration
        if d.min:
            self.set_min(d.min)
        if d.max:
            self.set_max(d.max)
        if d.progress:
            self.set_progress(d.progress)

        #: A really ugly way to add the target
        #: would be nice if we could just pass the block pointer here :)
        self.get_app().bridge.addTarget(
            self.widget,
            forControlEvents=UISlider.UIControlEventValueChanged,
            andCallback=self.widget.getId(),
            usingMethod="onValueChanged",
            withValues=["value"]#,"selected"]
        )

        self.widget.onValueChanged.connect(self.on_checked_changed)
692487
def getFirstLevel(self) :
		""""""
		res = []
		if len(self.children) > 0 :
			for c in self.children:
				res.append((c.x1, c.x2)) 
		else :
			if self.x1 != None :
				res = [(self.x1, self.x2)]
			else :
				res = None
		return res
1331539
function ( level, depth ) {
            if ( level >= depth ) {
                return this;
            }
            if ( this.childrenCount() === 0 ) {
                return;
            }

            for ( var i = 0, n = this.childrenCount(); i < n; i++ ) {
                var leftmostDescendant = this.childAt( i ).leftMost( level + 1, depth );
                if ( leftmostDescendant ) {
                    return leftmostDescendant;
                }
            }
        }
338871
@Pure
	public Object getTopContainer() {
		if (this.mapContainer == null) {
			return null;
		}
		final C container = this.mapContainer.get();
		if (container == null) {
			return null;
		}
		if (container instanceof GISContentElement<?>) {
			return ((GISContentElement<?>) container).getTopContainer();
		}
		return container;
	}