code: private static String getTopVarName(String name) {
      int firstDotIndex = name.indexOf('.');
      return firstDotIndex == -1 ? name : name.substring(0, firstDotIndex);
    }
docs: Gets the top variable name from a possibly namespaced name.
  
  @param name A variable or qualified property name (e.g. "a" or "a.b.c.d")
  @return The top variable name (e.g. "a")