Current implementation does not properly process cases where multiple blocks with equal block number could be contained in ancestors set. This causes algorithm to ignore such blocks when deciding when to stop (i.e. deciding that the current block is the answer), hence only a block with unique block number could every be chosen as the answer.
For example, LCA of b6 and b7 should be b4 as it is the parent for both of them. Current implementation, however, returns b1 as the answer since it is the most recent block which has a unique block number 1 (b4 and b5 both have block number 3, b2 and b3 both have block number 2).