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.
196771
def get_first_builder_window(builder):
    
    for obj in builder.get_objects():
        if isinstance(obj, gtk.Window):
            # first window
            return obj
1350555
def traverse_depth_first_pre_order(self, callback):
        
        n = len(self.suftab)
        root = [0, 0, n - 1, ""]  # <l, i, j, char>

        def _traverse_top_down(interval):  # TODO: Rewrite with stack? As in bottom-up
            callback(interval)
            i, j = interval[1], interval[2]
            if i != j:
                children = self._get_child_intervals(i, j)
                children.sort(key=lambda child: child[3])
                for child in children:
                    _traverse_top_down(child)

        _traverse_top_down(root)
502661
NodeBuilder ascendToRoot()
    {
        NodeBuilder current = this;
        while (!current.isRoot())
            current = current.ascend();
        return current;
    }
571302
public static WComponent getTop(final WComponent comp) {
		WComponent top = comp;

		for (WComponent parent = top.getParent(); parent != null; parent = parent.getParent()) {
			top = parent;
		}

		return top;
	}
362677
def get_toplevel_parent(self, treeitem):
        """"""
        tv = self.treeview
        toplevel_items = tv.get_children()

        item = treeitem
        while not (item in toplevel_items):
            item = tv.parent(item)

        return item
1297493
@Exported
    @QuickSilver
    public RunT getFirstBuild() {
        SortedMap<Integer, ? extends RunT> runs = _getRuns();

        if (runs.isEmpty())
            return null;
        return runs.get(runs.lastKey());
    }
1231289
public HierarchicalProperty getChild(QName name)
   {
      for (HierarchicalProperty child : children)
      {
         if (child.getName().equals(name))
            return child;
      }
      return null;
   }
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;
	}
800079
function(depth) {
        if (depth >= this.depth || depth < 0)  {
            this.logger.log("illegal getAncestor depth: " + depth);
            return null;
        }

        var p = this.parent;
        
        while (p.depth > depth) {
            p = p.parent;
        }

        return p;
    }
471229
def top_class(self):
        """"""
        curr = self
        parent = self.parent
        while isinstance(parent, class_t):
            curr = parent
            parent = parent.parent
        return curr
465192
def registerTopLevelWindow(self, window):
        
        # set the main window for this instance
        if not self._topLevelWindows:
            self.setPalette(window.palette())
            self.setWindowIcon(window.windowIcon())
            
            if self.splash():
                self.splash().finish(window)
        
        self._topLevelWindows.append(weakref.ref(window))
979650
function(widget, name) {

		if (Lava.schema.DEBUG && !name) Lava.t();

		while (widget && widget.name != name) {

			widget = widget.getParentWidget();

		}

		return widget;

	}
1228444
def set_toplevel_object(self, instance, class_=None):
        
        if class_ is None:
            class_ = type(instance)
        self._toplevels[class_] = instance
1053593
def _get_toplevel(path, user=None, password=None, output_encoding=None):
    '''
    
    '''
    return _git_run(
        ['git', 'rev-parse', '--show-toplevel'],
        cwd=path,
        user=user,
        password=password,
        output_encoding=output_encoding)['stdout']
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)
883209
public BType getBuilder() {
    if (builder == null) {
      // builder.mergeFrom() on a fresh builder
      // does not create any sub-objects with independent clean/dirty states,
      // therefore setting the builder itself to clean without actually calling
      // build() cannot break any invariants.
      builder = newBuilderForType(message.getDescriptorForType(), this);
      builder.mergeFrom(message); // no-op if message is the default message
      markClean(builder);
    }
    return builder;
  }
302987
function topLevelNodeBefore(node, top) {
    while (!node.previousSibling && node.parentNode != top)
      node = node.parentNode;
    return topLevelNodeAt(node.previousSibling, top);
  }