def check_existing_segment(self, socket_a, socket_b):
        """Check whether sockets are already connected."""
        ### check whether socket_b is inside socket_a
        ### children

        try:
            result = socket_b in socket_a.children

        ### if socket_a doesn't even have a 'children'
        ### attribute, that's ok, just pass
        except AttributeError:
            pass

        ### otherwise check whether socket_b is indeed
        ### among the socket_b children, in which case
        ### you must raise an error, since there's no
        ### point in connecting them again

        else:

            if result:

                raise ValueError("Sockets are connected already")
Check whether sockets are already connected.
nodezator/graphman/socketparenthood/support.py