GraphEdge (int nodeIndex, @Nullable Integer targetId, @NotNull GraphEdgeType edgeType) { if (edgeType.isNormalEdge()) { assert targetId != null; Integer anotherNodeIndex = myGetNodeIndexById.fun(targetId); if (anotherNodeIndex == null) return null; // todo edge to hide node return GraphEdge.createNormalEdge(nodeIndex, anotherNodeIndex, edgeType); } else { return GraphEdge.createEdgeWithTargetId(nodeIndex, targetId, edgeType); } }