Refactor getParentWithSkylarkModule() into SkylarkInterfaceUtils

--
MOS_MIGRATED_REVID=135956016
diff --git a/src/main/java/com/google/devtools/build/lib/syntax/EvalUtils.java b/src/main/java/com/google/devtools/build/lib/syntax/EvalUtils.java
index 9609544..2966781 100644
--- a/src/main/java/com/google/devtools/build/lib/syntax/EvalUtils.java
+++ b/src/main/java/com/google/devtools/build/lib/syntax/EvalUtils.java
@@ -13,7 +13,6 @@
 // limitations under the License.
 package com.google.devtools.build.lib.syntax;
 
-import com.google.common.annotations.VisibleForTesting;
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.Iterables;
@@ -155,31 +154,6 @@
         || c.equals(PathFragment.class); // other known class
   }
 
-  /**
-   * Returns a transitive superclass or interface implemented by c which is annotated
-   * with SkylarkModule. Returns null if no such class or interface exists.
-   */
-  @VisibleForTesting
-  static Class<?> getParentWithSkylarkModule(Class<?> c) {
-    if (c == null) {
-      return null;
-    }
-    if (c.isAnnotationPresent(SkylarkModule.class)) {
-      return c;
-    }
-    Class<?> parent = getParentWithSkylarkModule(c.getSuperclass());
-    if (parent != null) {
-      return parent;
-    }
-    for (Class<?> ifparent : c.getInterfaces()) {
-      ifparent = getParentWithSkylarkModule(ifparent);
-      if (ifparent != null) {
-        return ifparent;
-      }
-    }
-    return null;
-  }
-
   // TODO(bazel-team): move the following few type-related functions to SkylarkType
   /**
    * Return the Skylark-type of {@code c}
@@ -205,10 +179,7 @@
     }
     // TODO(bazel-team): also unify all implementations of ClassObject,
     // that we used to all print the same as "struct"?
-    //
-    // Check if one of the superclasses or implemented interfaces has the SkylarkModule
-    // annotation. If yes return that class.
-    Class<?> parent = getParentWithSkylarkModule(c);
+    Class<?> parent = SkylarkInterfaceUtils.getParentWithSkylarkModule(c);
     if (parent != null) {
       return parent;
     }