public function fieldByName($name)
    {
        if (strpos($name, '.') !== false) {
            list($name, $remainder) = explode('.', $name, 2);
        } else {
            $remainder = null;
        }

        foreach ($this as $child) {
            if (trim($name) == trim($child->getName()) || $name == $child->id) {
                if ($remainder) {
                    if ($child instanceof CompositeField) {
                        return $child->fieldByName($remainder);
                    } else {
                        $childClass = get_class($child);
                        user_error(
                            "Trying to get field '{$remainder}' from non-composite field {$childClass}.{$name}",
                            E_USER_WARNING
                        );
                        return null;
                    }
                } else {
                    return $child;
                }
            }
        }
        return null;
    }