added recursive versions of getOutgoing and getIncoming