Compare two name recursively.

    :param first_node: First node

    :param second_node: Second state

    :return: 0 if same name, 1 if names are differents.
764073
def cmp_name(first_node, second_node):
    
    if len(first_node.children) == len(second_node.children):
        for first_child, second_child in zip(first_node.children,
                                             second_node.children):
            for key in first_child.__dict__.keys():
                if key.startswith('_'):
                    continue
                if first_child.__dict__[key] != second_child.__dict__[key]:
                    return 1
            ret_val = cmp_name(first_child, second_child)
            if ret_val != 0:
                return 1
    else:
        return 1
    return 0
340462
def _compare_components(self, other, settings, ratio=False):
        """"""

        first = compare_name_component(
            self.first_list,
            other.first_list,
            settings['first'],
            ratio,
        )

        if settings['check_nickname']:
            if first is False:
                first = compare_name_component(
                    self.nickname_list,
                    other.first_list,
                    settings['first'],
                    ratio
                ) or compare_name_component(
                    self.first_list,
                    other.nickname_list,
                    settings['first'],
                    ratio
                )
            elif ratio and first is not 100:
                first = max(
                    compare_name_component(
                        self.nickname_list,
                        other.first_list,
                        settings['first'],
                        ratio
                    ),
                    compare_name_component(
                        self.first_list,
                        other.nickname_list,
                        settings['first'],
                        ratio
                    ),
                    first,
                )

        middle = compare_name_component(
            self.middle_list,
            other.middle_list,
            settings['middle'],
            ratio,
        )

        last = compare_name_component(
            self.last_list,
            other.last_list,
            settings['last'],
            ratio,
        )

        return first, middle, last
667441
public static boolean compareQNames(QName qn1, QName qn2) {
        if (qn1 == qn2)
            return true;
        if (qn1 == null || qn2 == null)
            return false;
        return qn1.equals(qn2);
    }
565742
def same_namespace?(node_1, node_2)
      args = [node_1,node_2]

      # CharacterData nodes shouldn't have namespaces. But in Nokogiri,
      # they do. And they're invisible. And they get corrupted easily.
      # So let's wilfully ignore them. And while we're at it, let's
      # ignore any class that doesn't know it has a namespace.
      if args.all? { |node| not node.is_namespaced? } or
         args.any? { |node| node.is_character_data? }
           return true
      end

      href1 = node_1.namespace_uri || ''
      href2 = node_2.namespace_uri || ''
      return href1 == href2
    end
1307517
def visit_Compare(self, node):
        """"""

        if len(node.ops) > 1:
            func = Name(id=self._prefix + 'napi_compare', ctx=Load())
            args = [node.left,
                    List(elts=[Str(op.__class__.__name__)
                               for op in node.ops], ctx=Load()),
                    List(elts=node.comparators, ctx=Load())]
            node = Call(func=func, args=args, keywords=self._kwargs)
            fml(node)
        self.generic_visit(node)
        return node
500563
public static boolean compareQNameLists(List<QName> list1, List<QName> list2) {
        if (list1 == list2)
            return true;
        if (list1 == null || list2 == null)
            return false;
        if (list1.size() != list2.size())
            return false;

        for (int i = 0; i < list1.size(); i++) {
            if (!compareQNames(list1.get(i), list2.get(i)))
                return false;
        }

        return true;
    }
1240839
def find_best_matching_node(self, new, old_nodes):
        
        name = new.__class__.__name__
        #: TODO: We should pick the BEST one from this list
        #: based on some "matching" criteria (such as matching ref name or params)
        matches = [c for c in old_nodes if name == c.__class__.__name__]
        if self.debug:
            print("Found matches for {}: {} ".format(new, matches))
        return matches[0] if matches else None
631763
def check_next_match(self, match, new_relations, subject_graph, one_match):
        """"""
        # avoid duplicate rings (order of traversal)
        if len(match) == 3:
            if match.forward[1] < match.forward[2]:
                #print "RingPattern.check_next_match: duplicate order", match.forward[1], match.forward[2]
                return False
        # avoid duplicate rings (starting point)
        for vertex1 in new_relations.values():
            if vertex1 < match.forward[0]:
                #print "RingPattern.check_next_match: duplicate start", vertex1, match.forward[0]
                return False
        # can this ever become a strong ring?
        for vertex1 in new_relations.values():
            paths = list(subject_graph.iter_shortest_paths(vertex1, match.forward[0]))
            if len(paths) != 1:
                #print "RingPattern.check_next_match: not strong 1"
                return False
            if len(paths[0]) != (len(match)+1)//2:
                #print "RingPattern.check_next_match: not strong 2"
                return False
        return True
1015058
function nodeValue(node1, node2) {
    return (node1.dist + heuristic(node1.point)) - (node2.dist + heuristic(node2.point));
  }
396665
def _bare_name_matches(self, nodes):
        """"""
        count = 0
        r = {}
        done = False
        max = len(nodes)
        while not done and count < max:
            done = True
            for leaf in self.content:
                if leaf[0].match(nodes[count], r):
                    count += 1
                    done = False
                    break
        r[self.name] = nodes[:count]
        return count, r
743503
public static <T> boolean isEqual(final T first, final T second) {
        /* test to see if they are both null, or both reference the same object */
        if (first == second) return true;

        if (first == null && second != null) return false;

        return first.equals(second);
    }
1012282
public boolean isSameAs( AstNode other ) {
        if (other == null) {
            return false;
        }
        if (!this.name.equals(other.name)) {
            return false;
        }
        if (!this.properties.equals(other.properties)) {
            return false;
        }
        if (this.getChildCount() != other.getChildCount()) {
            return false;
        }
        Iterator<AstNode> thisChildren = this.getChildren().iterator();
        Iterator<AstNode> thatChildren = other.getChildren().iterator();
        while (thisChildren.hasNext() && thatChildren.hasNext()) {
            if (!thisChildren.next().isSameAs(thatChildren.next())) {
                return false;
            }
        }
        return true;
    }
332348
def compare_trees(self, parsed_pytree, parsed_doctree):
        
        if parsed_pytree == parsed_doctree:
            return 0

        missing_pys, missing_docs = self.calculate_tree_differences(pytree=parsed_pytree,
                                                                    doctree=parsed_doctree)
        self.pprint_tree_differences(missing_pys=missing_pys, missing_docs=missing_docs)
        return 0 if self.args.no_fail else 1
223046
def equate_prefix(name1, name2):
    

    if len(name1) == 0 or len(name2) == 0:
        return False

    return name1.startswith(name2) or name2.startswith(name1)
500568
def is_none(node):
    '''
    '''
    if PY2:
        return isinstance(node, ast.Name) and node.id == 'None'
    return isinstance(node, ast.NameConstant) and node.value is None
399512
def visit_compare(self, node):
        """"""
        rhs_str = " ".join(
            [
                "%s %s" % (op, self._precedence_parens(node, expr, is_left=False))
                for op, expr in node.ops
            ]
        )
        return "%s %s" % (self._precedence_parens(node, node.left), rhs_str)
269743
def compare_trees(dir1, dir2):
    """"""
    paths1 = DirPaths(dir1).walk()
    paths2 = DirPaths(dir2).walk()
    return unique_venn(paths1, paths2)