How to find a key of a Map

I think this is the sense of my other question.

I’m trying the following. Early results are positive. It’s not dead slow as it was before.

I wonder if it is a bad idea to use pattern matching in the equals method.
There was a previous discussion about how to write a similar equal method.

case class BddNode(label:Int, positive:Bdd, negative:Bdd) extends Bdd {

  override def equals(that: Any): Boolean = {
    that match {
      case BddNode(l2:Int,p2:Bdd,n2:Bdd) => ( p2 eq positive) && (n2 eq negative) && (l2 == label)
      case _ => false
    }
  }

  override def hashCode(): Int =
    label.## ^ System.identityHashCode(positive) ^ ~System.identityHashCode(negative)

...
}