def get_property_by_inheritance(self, obj, prop):
        # pylint: disable=too-many-branches, too-many-nested-blocks
        """
        Get the property asked in parameter to this object or from defined templates of this
        object

        todo: rewrite this function which is really too complex!

        :param obj: the object to search the property
        :type obj: alignak.objects.item.Item
        :param prop: name of property
        :type prop: str
        :return: Value of property of this object or of a template
        :rtype: str or None
        """
        if prop == 'register':
            # We do not inherit the register property
            return None

        # If I have the property, I take mine but I check if I must add a plus property
        if hasattr(obj, prop):
            value = getattr(obj, prop)
            # Manage the additive inheritance for the property,
            # if property is in plus, add or replace it
            # Template should keep the '+' at the beginning of the chain
            if obj.has_plus(prop):
                if not isinstance(value, list):
                    value = [value]
                value.insert(0, obj.get_plus_and_delete(prop))
                value = list(set(value))
                if obj.is_tpl():
                    value.insert(0, '+')

            # Clean the returned value
            if isinstance(value, list):
                # Get unique ordered list
                new_list = []
                for elt in value:
                    if elt not in new_list:
                        new_list.append(elt)
                value = new_list
                if not obj.is_tpl():
                    while '+' in value:
                        value.remove('+')
            return value

        # Ok, I do not have prop, Maybe my templates do?
        # Same story for plus
        # We reverse list, so that when looking for properties by inheritance,
        # the least defined template wins (if property is set).
        for t_id in obj.templates:
            template = self.templates[t_id]
            value = self.get_property_by_inheritance(template, prop)

            if value is None or (isinstance(value, list) and not value):
                continue

            # If our template give us a '+' value, we continue the loop
            still_loop = False
            if isinstance(value, list) and value[0] == '+':
                # Templates should keep their + inherited from their parents
                if not obj.is_tpl():
                    value = list(value)
                    value = value[1:]
                still_loop = True

            # Maybe in the previous loop, we set a value, use it too
            if hasattr(obj, prop):
                # If the current value is a string, it will simplify the problem
                if isinstance(value, (list, string_types)) and value and value[0] == '+':
                    # In this case we can remove the + from our current
                    # tpl because our value will be final
                    new_val = list(getattr(obj, prop))
                    new_val.extend(value[1:])
                    value = new_val
                else:  # If not, we should keep the + sign of need
                    new_val = list(getattr(obj, prop))
                    new_val.extend(value)
                    value = new_val

            # Ok, we can set it and uniquify a list if needed
            if isinstance(value, list):
                # Get unique ordered list
                new_list = []
                for elt in value:
                    if elt not in new_list:
                        new_list.append(elt)
                value = new_list
                if not obj.is_tpl():
                    while '+' in value:
                        value.remove('+')

            setattr(obj, prop, value)

            # If we only got some '+' values, we must still loop
            # for an end value without it
            if not still_loop:
                # And set my own value in the end if need
                if obj.has_plus(prop):
                    # value = list(getattr(obj, prop, []))
                    value = list(value)
                    value.extend(obj.get_plus_and_delete(prop))
                    # Template should keep their '+'
                    if obj.is_tpl() and value[0] != '+':
                        value.insert(0, '+')

                    # Clean the returned value
                    if isinstance(value, list):
                        # Get unique ordered list
                        new_list = []
                        for elt in value:
                            if elt not in new_list:
                                new_list.append(elt)
                        value = new_list
                        if not obj.is_tpl():
                            while '+' in value:
                                value.remove('+')

                    setattr(obj, prop, value)
                return value

        # Maybe templates only give us + values, so we didn't quit, but we already got a
        # self.prop value after all
        template_with_only_plus = hasattr(obj, prop)

        # I do not have endingprop, my templates too... Maybe a plus?
        # warning: if all my templates gave me '+' values, do not forgot to
        # add the already set self.prop value
        if obj.has_plus(prop):
            if template_with_only_plus:
                value = list(getattr(obj, prop))
                value.extend(obj.get_plus_and_delete(prop))
            else:
                value = obj.get_plus_and_delete(prop)
            # Template should keep their '+' chain
            # We must say it's a '+' value, so our son will know that it must continue looping
            if obj.is_tpl() and value != [] and value[0] != '+':
                value.insert(0, '+')

            # Clean the returned value
            if isinstance(value, list):
                # Get unique ordered list
                new_list = []
                for elt in value:
                    if elt not in new_list:
                        new_list.append(elt)
                value = new_list
                if not obj.is_tpl():
                    while '+' in value:
                        value.remove('+')

            setattr(obj, prop, value)
            return value

        # Ok so in the end, we give the value we got if we have one, or None
        # Not even a plus... so None :)
        return getattr(obj, prop, None)
Get the property asked in parameter to this object or from defined templates of this
        object

        todo: rewrite this function which is really too complex!

        :param obj: the object to search the property
        :type obj: alignak.objects.item.Item
        :param prop: name of property
        :type prop: str
        :return: Value of property of this object or of a template
        :rtype: str or None