Prepare node for catalog endpoint

    Parameters:
        data (Union[str, dict]): Node ID or node definition
    Returns:
        Tuple[str, dict]: where first is ID and second is node definition

    Extract from /v1/health/service/<service>::

        {
            "Node": {
                "Node": "foobar",
                "Address": "10.1.10.12",
                "TaggedAddresses": {
                    "lan": "10.1.10.12",
                    "wan": "10.1.10.12"
                }
            },
            "Service": {...},
            "Checks": [...]
        }

def prepare_node(data):
    """Prepare node for catalog endpoint

    Parameters:
        data (Union[str, dict]): Node ID or node definition
    Returns:
        Tuple[str, dict]: where first is ID and second is node definition

    Extract from /v1/health/service/<service>::

        {
            "Node": {
                "Node": "foobar",
                "Address": "10.1.10.12",
                "TaggedAddresses": {
                    "lan": "10.1.10.12",
                    "wan": "10.1.10.12"
                }
            },
            "Service": {...},
            "Checks": [...]
        }
    """
    if not data:
        return None, {}

    if isinstance(data, str):
        return data, {}

    # from /v1/health/service/<service>
    if all(field in data for field in ("Node", "Service", "Checks")):
        return data["Node"]["Node"], data["Node"]

    result = {}
    if "ID" in data:
        result["Node"] = data["ID"]
    for k in ("Datacenter", "Node", "Address",
              "TaggedAddresses", "Service",
              "Check", "Checks"):
        if k in data:
            result[k] = data[k]
    if list(result) == ["Node"]:
        return result["Node"], {}
    return result.get("Node"), result