[master] Fixed cardinality calculations for bidirectional patterns and optional match