Paul put it this way:
Romans 2:1 Therefore thou art inexcusable, O man, whosoever thou art that judgest: for wherein thou judgest another, thou condemnest thyself; for thou that judgest doest the same things. 2 But we are sure that the judgment of God is according to truth against them which commit such things. 3 And thinkest thou this, O man, that judgest them which do such things, and doest the same, that thou shalt escape the judgment of God? 4 Or despisest thou the riches of his goodness and forbearance and longsuffering; not knowing that the goodness of God leadeth thee to repentance?
We have to check ourselves first, and repent if necessary, and then we can 'judge' out of a pure heart and with compassion.