What does the idiom "It takes one to know one" mean?

Review the verified answer and explanation for this PPSC Punjab Public Service Commission past-paper question on CampusFin.

What does the idiom "It takes one to know one" mean? Answer: Only an expert can identify another

“It takes one to know one” means that a person who possesses a particular characteristic is often able to recognize the same characteristic in another person. The expression is frequently used when discussing similar behavior, qualities, or faults.