private void expandCell(
            S2CellId parent, List <S2CellId> cells, IDictionary <S2CellId, S2CellId> parentMap)
        {
            cells.Add(parent);
            if (parent.Level == kMaxExpandLevel)
            {
                return;
            }
            var i           = 0;
            var j           = 0;
            int?orientation = 0;
            var face        = parent.ToFaceIjOrientation(ref i, ref j, ref orientation);

            JavaAssert.Equal(face, parent.Face);

            var pos = 0;

            for (var child = parent.ChildBegin; !child.Equals(parent.ChildEnd);
                 child = child.Next)
            {
                // Do some basic checks on the children
                JavaAssert.Equal(child.Level, parent.Level + 1);
                Assert.True(!child.IsLeaf);
                int?childOrientation = 0;
                JavaAssert.Equal(child.ToFaceIjOrientation(ref i, ref j, ref childOrientation), face);
                JavaAssert.Equal(
                    childOrientation.Value, orientation.Value ^ S2.PosToOrientation(pos));

                parentMap.Add(child, parent);
                expandCell(child, cells, parentMap);
                ++pos;
            }
        }