How to check if an element is connected to some other element ? There should at-least one incoming or one outgoing or both.