code: private PMap<TypedScope, OverlayScope> trimScopes(TypedScope scope) {
      TypedScope thisScope = syntacticScope;
      TypedScope thatScope = scope;
      int thisDepth = thisScope.getDepth();
      int thatDepth = thatScope.getDepth();
      PMap<TypedScope, OverlayScope> result = scopes;
      while (thatDepth > thisDepth) {
        thatScope = thatScope.getParent();
        thatDepth--;
      }
      while (thisDepth > thatDepth) {
        result = result.minus(thisScope);
        thisScope = thisScope.getParent();
        thisDepth--;
      }
      while (thisScope != thatScope && thisScope != null && thatScope != null) {
        result = result.minus(thisScope);
        thisScope = thisScope.getParent();
        thatScope = thatScope.getParent();
      }
      return result;
    }
docs: Returns the scope map, trimmed to the common ancestor between this FlowScope's syntacticScope
  and the given scope. Any inferred types on variables in deeper scopes cannot be propagated past
  this point (since they're no longer in scope), and trimming them eagerly allows us to ignore
  these irrelevant types when checking equality and joining.