public Device GetDeviceById(string deviceId)
        {
            var spaces  = Spaces.Flatten <Space>(s => s.childSpaces);
            var devices = spaces.Where(s => s.devices != null && s.devices.Any()).SelectMany(s => s.devices);

            return(devices.FirstOrDefault(d => d != null && d.id == deviceId));
        }
        public Space GetSpaceById(string spaceId)
        {
            var space = Spaces.FirstOrDefault(s => s.id == spaceId);

            if (space == null)
            {
                space = Spaces.Flatten <Space>(s => s.childSpaces).FirstOrDefault(s => s.id == spaceId);
            }

            return(space);
        }