@Nonnull
	private String getCommon(@Nonnull InheritanceVertex firstVertex, @Nonnull String first, @Nonnull String second) {
		// Full upwards hierarchy for the first
		SequencedSet<String> firstParents = firstVertex.allParents()
				.map(InheritanceVertex::getParentAndCurrentNames)
				.flatMap(Collection::stream)
				.collect(Collectors.toCollection(LinkedHashSet::new));
		firstParents.add(first);

		// Ensure 'Object' is last
		firstParents.remove(OBJECT);
		firstParents.add(OBJECT);

		// Base case
		if (firstParents.contains(second))
			return second;

		// Iterate over second's parents via breadth-first-search
		Queue<String> queue = new LinkedList<>();
		queue.add(second);
		do {
			// Item to fetch parents of
			String next = queue.poll();
			if (next == null || next.equals(OBJECT))
				continue;

			InheritanceVertex nextVertex = getVertex(next);
			if (nextVertex == null)
				continue;

			for (String parent : nextVertex.getParents().stream()
					.map(InheritanceVertex::getParentAndCurrentNames)
					.flatMap(Collection::stream)
					.toList()) {
				if (!parent.equals(OBJECT)) {
					// Parent in the set of visited classes? Then its valid.
					if (firstParents.contains(parent))
						return parent;
					// Queue up the parent
					queue.add(parent);
				}
			}
		} while (!queue.isEmpty());

		// Fallback option
		return OBJECT;
	}
@param firstVertex
		Vertex of the {@code first} name.
@param first
		First class name.
@param second
		Second class name.

@return Common parent of the classes.
recaf-core/src/main/java/software/coley/recaf/services/inheritance/InheritanceGraph.java