code: private void flattenNameRefAtDepth(String alias, Node n, int depth,
        String originalName) {
      // This method has to work for both GETPROP chains and, in rare cases,
      // OBJLIT keys, possibly nested. That's why we check for children before
      // proceeding. In the OBJLIT case, we don't need to do anything.
      Token nType = n.getToken();
      boolean isQName = nType == Token.NAME || nType == Token.GETPROP;
      boolean isObjKey = NodeUtil.mayBeObjectLitKey(n);
      checkState(isObjKey || isQName);
      if (isQName) {
        for (int i = 1; i < depth && n.hasChildren(); i++) {
          n = n.getFirstChild();
        }
        if (n.isGetProp() && n.getFirstChild().isGetProp()) {
          flattenNameRef(alias, n.getFirstChild(), n, originalName);
        }
      }
    }
docs: Flattens a particular prefix of a single name reference.
  
  @param alias A flattened prefix name (e.g. "a$b")
  @param n The node corresponding to a subproperty name (e.g. "a.b.c.d")
  @param depth The difference in depth between the property name and
  the prefix name (e.g. 2)
  @param originalName String version of the property name.