Try to avoid using return as part of the control flow.

You can rewrite this as

    if (rdds.size > 1 && rdds.head.partitioner != None) {
      val part = rdds.head.partitioner
      rdds.find(_.partitioner != part).isDefined
    } else {
      false
    }