Using the lowercase name of the class as node_type, returns `obj.visit_{node_type}`,
    or `obj.visit_default` if the type-specific method is not found.
13181
def get(self, obj, cls):
    
    method = self._cache.get(cls)
    if not method:
      name = "visit_" + cls.__name__.lower()
      method = getattr(obj, name, obj.visit_default)
      self._cache[cls] = method
    return method
116670
def generic_visit(self, node):
        """"""
        # [[[cog
        # cog.out("print(pcolor('Enter generic visitor', 'magenta'))")
        # ]]]
        # [[[end]]]
        # A generic visitor that potentially closes callables is needed to
        # close enclosed callables that are not at the end of the enclosing
        # callable, otherwise the ending line of the enclosed callable would
        # be the ending line of the enclosing callable, which would be
        # incorrect
        self._close_callable(node)
        super(_AstTreeScanner, self).generic_visit(node)
368560
def _get_node_type(self, node):
        
        if node == BLANK_NODE:
            return NODE_TYPE_BLANK

        if len(node) == 2:
            nibbles = unpack_to_nibbles(node[0])
            has_terminator = (nibbles and nibbles[-1] == NIBBLE_TERMINATOR)
            return NODE_TYPE_LEAF if has_terminator\
                else NODE_TYPE_EXTENSION
        if len(node) == 17:
            return NODE_TYPE_BRANCH
585810
def find_object(self, object_type):
        """"""
        node = self
        while node is not None:
            if isinstance(node.obj, object_type):
                return node.obj
            node = node.parent
1095576
function getNthElementOfType(context, element, index) {
  let nthOfType = 0;
  for (let i = 0, child; (child = context.children[i]); i++) {
    if (child.nodeType === child.ELEMENT_NODE &&
        child.tagName.toLowerCase() === element.tagName.toLowerCase()) {
      if (nthOfType === index) {
        return child;
      }
      nthOfType++;
    }
  }
  return null;
}
777435
def _visit_or_none(node, attr, visitor, parent, visit="visit", **kws):
    
    value = getattr(node, attr, None)
    if value:
        return getattr(visitor, visit)(value, parent, **kws)

    return None
1054741
def _get_node_name(self, node):
        """"""
        res = getattr(node, "name", None)
        if res is None:
            return res

        if isinstance(res, AST.TypeDecl):
            return res.declname
        
        return res
943548
public void visitDefault(GroovySourceAST t,int visit) {
        if (visit == OPENING_VISIT) {
            print(t,visit,"<" + tokenNames[t.getType()] + ">");
            //out.print("<" + t.getType() + ">");
        } else {
            print(t,visit,"</" + tokenNames[t.getType()] + ">");
            //out.print("</" + t.getType() + ">");
        }
    }
188535
private ObjectType findMethodOwner(Node n) {
    if (n == null) {
      return null;
    }
    Node parent = n.getParent();
    FunctionType ctor = null;
    if (parent.isAssign()) {
      Node target = parent.getFirstChild();
      if (NodeUtil.isPrototypeProperty(target)) {
        // TODO(johnlenz): handle non-global types
        JSType type = registry.getGlobalType(target.getFirstFirstChild().getQualifiedName());
        ctor = type != null ? ((ObjectType) type).getConstructor() : null;
      }
    } else if (parent.isClass()) {
      // TODO(sdh): test this case once the type checker understands ES6 classes
      ctor = parent.getJSType().toMaybeFunctionType();
    }
    return ctor != null ? ctor.getInstanceType() : null;
  }
122301
def get(self, key, default=None):
		
		if key in self._nodes: return self._nodes[key]
		else: return default
893726
def visit(self, node):
        
        method = getattr(self, 'visit_' + node.expr_name, self.generic_visit)

        # Call that method, and show where in the tree it failed if it blows
        # up.
        try:
            # Changing this to reverse here!
            return method(node, [self.visit(child) for child in reversed(list(node))])
        except (VisitationError, UndefinedLabel):
            # Don't catch and re-wrap already-wrapped exceptions.
            raise
        except self.unwrapped_exceptions:
            raise
        except Exception: # pylint: disable=broad-except
            # Catch any exception, and tack on a parse tree so it's easier to
            # see where it went wrong.
            exc_class, exc, traceback = exc_info()
            reraise(VisitationError, VisitationError(exc, exc_class, node), traceback)
539088
def get_default(self, node):
        
        if node.inst.properties.get("onwrite", None) == rdltypes.OnWriteType.woclr:
            return True
        else:
            return self.default
1169290
function (el, type) {
		while (el && el.nodeName.toLowerCase() !== type.toLowerCase()) {
			el = el.parentNode;
		}
		return el;
	}
1338120
def _check_node(self, obj):
        """"""
        if not issubclass(type(obj), self.definition['node_class']):
            raise ValueError("Expected node of class " + self.definition['node_class'].__name__)
        if not hasattr(obj, 'id'):
            raise ValueError("Can't perform operation on unsaved node " + repr(obj))
319912
def get_node_type(tree):
    
    if isinstance(tree, (RSTTree, nltk.tree.Tree)):
        if tree.label() in ('N', 'S'):
            return tree.label()
        else:
            return 'relation'
    elif isinstance(tree, basestring):
        return 'edu'
    else:
        raise ValueError("Unknown tree/node type: {}".format(type(tree)))
753087
private String getDefaultInstanceName() {
            String name = getDefinition().getName() + " #";
            int i = 0;
            Treeview tree = node.getTreeview();

            while (TreeUtil.findNodeByLabel(tree, name + ++i, false) != null) {}
            return name + i;
        }
715998
def _traverse_parent(node, objtypes):
    
    curr_node = node.parent
    while curr_node is not None:
        if isinstance(curr_node, objtypes):
            return curr_node
        curr_node = curr_node.parent
    return None