Implemented a naive algorithm to determine the common supertype