Return the nearest ancestor that is an instance of the provided
class or mixin.

@method nearestOfType
@param {Class,Mixin} klass Subclass of Ember.View (or Ember.View itself),
or an instance of Ember.Mixin.
@return Ember.View
773519
function(klass) {
        var view = get(this, 'parentView');
        var isOfType = klass instanceof Mixin ?
                       function(view) { return klass.detect(view); } :
                       function(view) { return klass.detect(view.constructor); };

        while (view) {
          if (isOfType(view)) { return view; }
          view = get(view, 'parentView');
        }
      }
139698
function inheritsFrom(validatedClass, expectedParentClass, errorText) {
  if (
    //fail-fast if it is nil
    !validatedClass ||
    //lenient check whether class directly or indirectly inherits from expected class
    (!(validatedClass.prototype instanceof expectedParentClass) &&
      validatedClass !== expectedParentClass)
  ) {
    throw new ValidationError(
      errorText || `Validated class does not inherit from ${expectedParentClass.name}`
    );
  }
  return validatedClass;
}
995548
function(o) {
		return gui.Type.isConstructor(o) &&
			gui.Class.ancestorsAndSelf(o).indexOf(edb.Array) > -1;
	}
391890
function closest(e, classname) {
    if ($(e).hasClass(classname)) {
        return e;
    }
    return e.parentNode && closest(e.parentNode, classname);
}
330597
function nearestBody() {
            const ancestors = context.getAncestors();
            let ancestor = ancestors.pop(),
                generation = 1;

            while (ancestor && ["Program", "FunctionDeclaration",
                "FunctionExpression", "ArrowFunctionExpression"
            ].indexOf(ancestor.type) < 0) {
                generation += 1;
                ancestor = ancestors.pop();
            }

            return {

                // Type of containing ancestor
                type: ancestor.type,

                // Separation between ancestor and node
                distance: generation
            };
        }
1346430
def _toplevel(cls):
        
        superclasses = (
            list(set(ClosureModel.__subclasses__()) &
                 set(cls._meta.get_parent_list()))
        )
        return next(iter(superclasses)) if superclasses else cls
616983
function ( el, selector, rootEl ) {
            var root = rootEl || document,
                parent = el.parentNode;
    
            if ( parent && parent != root ) {
                var match = this.match( parent, selector );
                return match? parent : this.closest( parent, selector );
            } else {
                return;
            }
        }
1210019
def get_proxy_ancestor_classes(klass):
    
    proxy_ancestor_classes = set()
    for superclass in klass.__bases__:
        if hasattr(superclass, '_meta') and superclass._meta.proxy:
            proxy_ancestor_classes.add(superclass)
        proxy_ancestor_classes.update(
            get_proxy_ancestor_classes(superclass))
    return proxy_ancestor_classes
1200589
def get_ancestor_object_by_type(self, obj_type):
        

        if self.type.lower() == obj_type.lower():
            return self
        else:
            if not self.parent:
                return None
            return self.parent.get_ancestor_object_by_type(obj_type)
1225012
@Override
  public SubclassRelationship getClassesDefinedByCall(Node callNode) {
    SubclassRelationship relationship =
        super.getClassesDefinedByCall(callNode);
    if (relationship != null) {
      return relationship;
    }

    Node callName = callNode.getFirstChild();
    SubclassType type = typeofClassDefiningName(callName);
    if (type != null) {
      Node subclass = null;
      Node superclass = callNode.getLastChild();

      // There are four possible syntaxes for a class-defining method:
      // goog.inherits(SubClass, SuperClass)
      // goog$inherits(SubClass, SuperClass)
      // goog.mixin(SubClass.prototype, SuperClass.prototype)
      // goog$mixin(SubClass.prototype, SuperClass.prototype)
      if (callNode.hasXChildren(3)) {
        // goog.inherits(SubClass, SuperClass)
        subclass = callName.getNext();
      } else {
        return null;
      }

      if (type == SubclassType.MIXIN) {
        // Only consider mixins that mix two prototypes as related to
        // inheritance.
        if (!endsWithPrototype(superclass)) {
          return null;
        }
        if (!endsWithPrototype(subclass)) {
          return null;
        }
        // Strip off the prototype from the name.
        subclass = subclass.getFirstChild();
        superclass = superclass.getFirstChild();
      }

      // bail out if either of the side of the "inherits"
      // isn't a real class name. This prevents us from
      // doing something weird in cases like:
      // goog.inherits(MySubClass, cond ? SuperClass1 : BaseClass2)
      if (subclass != null
          && subclass.isUnscopedQualifiedName()
          && superclass.isUnscopedQualifiedName()) {
        return new SubclassRelationship(type, subclass, superclass);
      }
    }

    return null;
  }
1340775
public Class<?> getFarType(Class<?> nearType) {
        if (!nearToFarType.containsKey(nearType)) {
            throw new IllegalStateException("Near type not registered: " + (nearType == null ? "null" : nearType.getSimpleName()));
        }
        return nearToFarType.get(nearType);
    }
1266327
def klass_for_type(type, singular=false)
      type = type.singularize unless singular
      type.classify.constantize
    end
388987
def get_next_instance(self, obj):
        
        ordered_siblings = obj.get_siblings().filter(placeholder=obj.placeholder).order_by('position')
        pos = list(ordered_siblings).index(obj.cmsplugin_ptr)
        if pos < ordered_siblings.count() - 1:
            next_sibling = ordered_siblings[pos + 1]
            return next_sibling.get_bound_plugin()
1357167
public static <T extends Tree> Matcher<T> isInstance(final java.lang.Class<?> klass) {
    return new Matcher<T>() {
      @Override
      public boolean matches(T t, VisitorState state) {
        return klass.isInstance(t);
      }
    };
  }
1124806
private boolean ancestorIsTemplated(TypeElement type) {
        while (true) {
            TypeMirror parentMirror = type.getSuperclass();
            if (parentMirror.getKind() == TypeKind.NONE) {
                return false;
            }
            TypeElement parentElement = (TypeElement) typeUtils.asElement(parentMirror);
            if (parentElement.getAnnotation(Templated.class) != null) {
                return true;
            }
            type = parentElement;
        }
    }
1310577
def lookup_ancestors #:nodoc:
      klass = self
      classes = [klass]
      return classes if klass == ActiveRecord::Base

      while klass != klass.base_class
        classes << klass = klass.superclass
      end
      classes
    end
1163419
function getClosestInstanceFromNode(node) {
  if (node[internalInstanceKey]) {
    return node[internalInstanceKey];
  }

  // Walk up the tree until we find an ancestor whose instance we have cached.
  var parents = [];
  while (!node[internalInstanceKey]) {
    parents.push(node);
    if (node.parentNode) {
      node = node.parentNode;
    } else {
      // Top of the tree. This node must not be part of a React tree (or is
      // unmounted, potentially).
      return null;
    }
  }

  var closest;
  var inst;
  for (; node && (inst = node[internalInstanceKey]); node = parents.pop()) {
    closest = inst;
    if (parents.length) {
      precacheChildNodes(inst, node);
    }
  }

  return closest;
}