Resolve variables recursively